Closed
Description
I noticed that the values calculated by the trans
formula for sec_axis
are incorrect.
In particular, I want to give the log values and have a sec_axis
that plots both the log and non-log values.
It seems to be a problem when the trans
formula has an exponential form other than exp
.
Minimal reproducible example:
df=data.frame(x=seq(from=0,to=-0.95,by=-0.05) , y=rnorm(20))
# just some numbers between [-1,0] on x axis.
# They are intended to represent logarithmic values, and the the goal
# is to plot the non-logarithmic values as a second y-axis.
# Note the simple change of base to log10
ggplot(data=df , aes( x = x/log(10) , y = y ) ) +
geom_point() +
scale_x_continuous(sec.axis = sec_axis(~10^(.)) )
Since all x
values are in [0,1]
, then by definition, the sec_axis
should not give any values above 1
. But it does. Note how the rightmost data point on the x-axis has log value = 0, but on the secondary axis it has value > 1.0. This is, of course, incorrect since a^0 = 1
for all numbers a
.
Metadata
Metadata
Assignees
Labels
No labels