Comments (4)
Alright thanks for the interest anyway! Making examples strikes again as an excellent bugfix :)
from ggh4x.
There shouldn't be a conflict (not saying that there isn't). Could you provide some example with one of the built-in datasets of where this approach fails?
from ggh4x.
Thanks for such a prompt response. Here's some code. I might have been able to narrow down this issue. With this example it looks like the breaks are being set, but the limits are not being recognised. If I don't set any limits, the axes are restricted to the values in the data, and so there are no axes values if they aren't in that range. If I set only one of the limits and use 'NA' in the other, then that is ignored.
So, it looks like I need to manually set both the limits for this to work. Perhaps that is how the function is supposed to behave. Sorry if this is the case and I just didn't read the documentation correctly!
# Subet some example data
DATA <- mpg[mpg$manufacturer %in% c("dodge", "ford") & mpg$class %in% c("pickup", "suv"),]
# Set custom x axes breaks
CUSTOM.BREAKS <- list(
scale_x_continuous(breaks = c(5, 6, 17, 23)), # Top left plot, will only plot data, no axes values
scale_x_continuous(breaks = c(0, 10, 15, 20, 25), limits = c(0, NA)), # Top right plot,
honours the lower limit,
so shows '0' and '10' on the axes, but not 15+
scale_x_continuous(breaks = c(0, 10, 15, 20, 25), limits = c(0, 25)), # Second from top on left,
shows full range of values.
scale_x_continuous(breaks = c(5, 6, 17, 23)),
scale_x_continuous(breaks = c(10, 20, 30)),
scale_x_continuous(breaks = c(9, 10, 11, 12, 13, 14, 15, 16, 17, 18)),
scale_x_continuous(breaks = c(11, 22, 33)),
scale_x_continuous(breaks = c(8, 16, 24))
)
# Set strip theme
PLOT.STRIPS <- strip_nested(
text_y = elem_list_text(
colour = c(rep("white", 2), rep("black", 4))),
background_y = elem_list_rect(
fill = c("#210c4a", "#8a226a", rep(c("#bc3754", "#f9cb35"), 2))),
by_layer_y = FALSE
)
# Plot
ggplot(DATA, aes(cty, hwy)) +
geom_point() +
facet_grid2(year + class ~ manufacturer, scales = "free", independent = "x", axes = "y",
remove_labels = "y", strip = PLOT.STRIPS) +
facetted_pos_scales(x = CUSTOM.BREAKS)
from ggh4x.
And after some more testing with my real data, I realise that nesting the facets will also change the plotting order I was expecting when setting the custom breaks.
Going to close this now. So sorry I posted before I realised I was doing something wrong. The package is working brilliantly.
from ggh4x.
Related Issues (20)
- Text aesthetics in nested facets not working HOT 2
- Cannot use `trans` after using `facetted_pos_scales` HOT 3
- Release ggh4x 0.2.7
- facet_nested have a different behaviour as compare to facet_grid when combining character and numeric HOT 2
- facet_wrap2 adding wrong x axis labels HOT 3
- Facet size = "variable" not working? HOT 2
- Release ggh4x 0.2.8
- match facet data with ggbarplot HOT 4
- Missing data prevents setting up secondary y-axis scale in help_sec_range and help_sec_max HOT 1
- Ggplotly will move x-axis back to default position HOT 1
- Add tag_facet function? HOT 5
- Error when facetting and using `ggtext` HOT 3
- geom_rectmargin won't work bug with fill_alpha HOT 3
- ggtext::element_markdown not working with ggh4x_0.2.8 HOT 3
- Remove x-axis labels with independent = "x" if they are identical HOT 4
- Add compatibility with ggtext::element_markdown() HOT 1
- Error in check_object(cols, is_quosures, "a {.fn vars} specification" HOT 3
- facet_grid with remove_labels removes labels but leaves the space between the panels HOT 2
- `guide_stringlegend()` throws `Error in get_layer_key(...) : argument "data" is missing, no default` HOT 4
- S3 guide system deprecated in ggplot2 3.5.0 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ggh4x.