CodePudding user response:
There's nothing wrong with your trans function. It's the way that you are using geom_errorbar
that is problematic. Since, for some reason, you are not mapping the ymin
and ymax
aesthetics to the appropriate columns, but instead passing them as geom parameters outside of aes
, they are not being used when calculating the correct range for the panel.
df %>%
ggplot(aes(x=state, y= value, color = grp, group = grp))
geom_point(position=position_dodge(.7))
geom_errorbar(aes(ymin = rangeL, ymax= rangeU),
position=position_dodge(.7), width = 0.5)
scale_y_continuous(trans = squish_trans(25, 75, 10),
breaks = c(0, 5, 10, 20, 25, 75, 100))