Closed
Description
Hi,
I have been trying to plot continuous data with a log-scaled x-axis and a secondary x-axis in order to display ticks values in another unit.
It seems to me that the ticks positions of this secondary axis are not correctly computed.
Here is a reproducible example:
foo <- tibble(x = exp(seq(log(0.001), log(1000), length.out = 100)), y = x/(1+x))
ggplot(foo, aes(x, y))+
geom_point()+
scale_x_log10(name = "Unit A",
breaks = c(0.001, 0.01, 0.1, 1, 10, 100, 1000),
sec.axis = sec_axis(~. * 100, name = "Unit B",
labels = derive(),
breaks = derive()))
Considering the transformation (x * 100
), ticks positions do not correspond.
Also, dup_axis()
does not duplicate the original axis:
ggplot(foo, aes(x, y))+
geom_point()+
scale_x_log10(name = "Unit A",
breaks = c(0.001, 0.01, 0.1, 1, 10, 100, 1000),
sec.axis = dup_axis())
Am I doing something wrong?