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?
DavoWW
July 31, 2023, 5:02am
2
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.
tidyverse:main
← teunbrand:zero_domain
opened 06:33PM - 19 Apr 23 UTC
This PR aims to fix #5271.
Briefly, `reciprocal_trans()`'s domains are [-Inf,… Inf]. The reciprocal of this domain is [0,0]. The limits get squished to [0,0]. We cannot compute breaks on this. Hence, in this PR, we refuse to squish limits to zero-range domains.
Moreover, it adds a series of tests for computing breaks with almost all transformd (boxcox is broken though), so we might see better when we might break a particular transfomation.
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!
system
Closed
August 8, 2023, 10:29pm
6
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.