Hi there!
I am trying to represent a logarithmic series using a y log scale in ggplot2, but I need the y axis labels to be equidistant. For a reason I don't understand, it seems that when the y series is 1000 or lower, the y labels are NOT equidistant, but when the y series is 10000 or higher, the y labels ARE equidistant.
Below, a couple examples with linear and logarithmic series (these are a minimal reproducible example of what I am doing. In reality, I am editing the labels to be "1 out of x", and representing the data in a heatmap).
In brief, there is any way to "force" the y axis lables to be equidistant when using scale_y_log10()?
Thanks!
library(tidyverse)
# Log series in a log scale. Y lables NOT equidistant when the series are <=1000
tibble(X = 1, Y = exp(seq(log(1), log(1000), length.out = 100))) %>%
ggplot(aes(X, Y)) +
geom_point() +
scale_y_log10(n.breaks = 10, expand = c(0,0))
# Log series in a log scale. Y lables ARE equidistant when the series are >=10000
tibble(X = 1, Y = exp(seq(log(1), log(10000), length.out = 100))) %>%
ggplot(aes(X, Y)) +
geom_point() +
scale_y_log10(n.breaks = 10, expand = c(0,0))
# Same with a linear series in a log scale
tibble(X = 1, Y = 1:10^3) %>%
ggplot(aes(X, Y)) +
geom_point() +
scale_y_log10(n.breaks = 10, expand = c(0,0))
tibble(X = 1, Y = 1:10^4) %>%
ggplot(aes(X, Y)) +
geom_point() +
scale_y_log10(n.breaks = 10, expand = c(0,0))
Created on 2021-12-13 by the reprex package (v2.0.1)