Cannot add breaks when using "reciprocal" transformation

I can't seem to add x-axis breaks when using the "reciprocal" transformation in scale_x_continuous. Given the following dummy data

p <- tibble(x = c(1, 3, 10, 30),
            y = 1:4) %>%
    ggplot(aes(x, y, label = x)) + 
    geom_text()
p

I can add breaks just fine as is. (I've skipped the break at 3 on purpose to show that I'm manually overriding the defaults.)

p + scale_x_continuous(breaks = c(1, 10, 30))

In another transformation like "log10", the custom breaks are fine.

p + scale_x_continuous(trans = "log10", breaks = c(1, 10, 30))

But when I use "reciprocal", not only are they missing when breaks is not specified, but they're also missing when breaks is specified.

p + scale_x_continuous(trans = "reciprocal", breaks = c(1, 10, 30))

Is this a bug or am I doing something wrong?

Hi @joeystan
I'm not at my PC but what happens if you use

breaks = c(1, 0.1, 0.0333)

seems to have been a known issue, that got fixed in development version, but has not been delivered into a release version of ggplot2, that does seem quite odd to me but all the same, if you need this in the short term, using the development version of ggplot2 is the way to go.

Still no dice. I've tried lots of different breaks, thinking my conversions were wrong, but nothing shows up.

Thank you! I'll see if I can get the development version!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.