Closed
Description
It appears that sec_axis is no longer working correctly with transformed axes. In particular, the secondary axis ticks and labels seem to be misaligned when using trans = 'sqrt'
:
library(ggplot2)
data <- data.frame(
x = seq(0, 1, length.out = 100),
y = seq(0, 4, length.out = 100)
)
ggplot(data, aes(x, y)) +
geom_line() +
scale_y_continuous(trans = 'sqrt', sec.axis = dup_axis())
Created on 2018-11-02 by the reprex package (v0.2.1)
The issue only seems to occur when zero is one of the data points (note the lower limit for y
is changed to 0.01):
library(ggplot2)
data <- data.frame(
x = seq(0, 1, length.out = 100),
y = seq(0.01, 4, length.out = 100)
)
ggplot(data, aes(x, y)) +
geom_line() +
scale_y_continuous(trans = 'sqrt', sec.axis = dup_axis())
Created on 2018-11-02 by the reprex package (v0.2.1)
The issue doesn't show up for trans = 'log'
or trans = 'log10'
, probably because they filter zero. I have also tested with a custom cube root transform and it has the same issue as square root.
Metadata
Metadata
Assignees
Labels
No labels