Closed EcologyTom closed 1 year ago
Oh, I'm sorry. I looked again at the documentation and realised I should be using facetted_pos_scales(x = CUSTOM.BREAKS)
because I'm changing the x axis.
Yep, that's right. Perhaps the error message should be a little more helpful on this.
There is also scale_x_facet()
to do a similar thing without bothering with lists.
Thanks. Perhaps a slight edit to the manual text for facetted_pos_scales
might help? Just my opinion of course, but to me "axes" would be more intuitive than "position" in this context.
I also noticed that even when I set the breaks, sometimes the first or last values are missing. Is it possible to force a tick mark to show at 0, for example?
Yeah that should be possible by including 0 in the limits. If you have no negative values, you can use limits = c(0, NA)
. If you do have negative values and you want to include 0, you can use limits = ~ c(pmin(.x[1], 0), .x[2])
.
While 'axes' sound more intuitive, 'position scales' as a term in ggplot2 is what is really being altered, so I'm not keen on changing the terms away from what ggplot2 uses.
Error should now read more informative text:
devtools::load_all("~/packages/ggh4x")
#> ℹ Loading ggh4x
#> Loading required package: ggplot2
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
facetted_pos_scales(x = list(scale_y_continuous()))
#> Error in `facetted_pos_scales()`:
#> ! The `x` argument should be "NULL", or a list of formulas and/or
#> position scales with the x aesthetic.
Created on 2023-03-28 with reprex v2.0.2
Hi,
Many thanks for ggh4x, it's great. I want to create custom breaks in a 40 panel plot I've created with facet_grid2. Each panel needs custom x breaks. Following an answer on SO I created a list with my custom breaks like so:
And refer to the list in the ggplot call:
+ facetted_pos_scales(y = CUSTOM.BREAKS)
but this returns:I must be referring to the panels incorrectly. I'm unclear how I could refer to the individual panels directly in
facetted_pos_scales
, the help file refers to only rows or columns. Please could you give some direction on how to set the breaks for each the indivudal panel? Many thanks.