teunbrand / ggh4x

ggplot extension: options for tailored facets, multiple colourscales and miscellaneous
https://teunbrand.github.io/ggh4x/
Other
534 stars 32 forks source link

vertical lines as separator between categorical groups in nested axis #123

Closed johanneswerner closed 10 months ago

johanneswerner commented 10 months ago

First example from: https://teunbrand.github.io/ggh4x/reference/guide_axis_nested.html

# The defaults are suited for interaction variables
ggplot(mpg, aes(interaction(cyl, class), hwy)) +
  geom_boxplot() +
  scale_x_discrete(guide = "axis_nested")

Is it possible for clearer separation to add vertical lines between each group of the x axis?

Second, unrelated question: How can I show all cylinders for each car class? (i.e. can I show the values 4, 5, 6 and 8 for each car class without adding dummy data to the data frame)

Thank you!

teunbrand commented 10 months ago

Hi there,

Is it possible for clearer separation to add vertical lines between each group of the x axis?

No, only horizontal indicators are possible. I don't plan on honouring any feature requests for guides at the moment, because I'm developing a separate package for this.

Second, unrelated question: How can I show all cylinders for each car class? (i.e. can I show the values 4, 5, 6 and 8 for each car class without adding dummy data to the data frame)

You can use drop = FALSE in the scale if you use interaction() in the aesthetic. Otherwise, you might have to set the scale's limits/breaks manually.

johanneswerner commented 9 months ago

Thanks for letting me know and an answer for my second question. If you don't mind, what is the package name? Or is it not public (yet)?

teunbrand commented 9 months ago

You can find the package here, but it certainly won't work without the development version of ggplot2.