Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misalignment of ticks and text labels when using guide_axis_nested() from legendry with coord_flip() #70

Closed
greengeckoruns opened this issue Mar 6, 2025 · 2 comments

Comments

@greengeckoruns
Copy link

Hello everyone,

I have noticed a difference in behavior of guide_axis_nested() from legendry versus ggh4x when using coord_flip(). Using the below code for reprex.

ggplot(mpg, aes(interaction(cyl, class), hwy)) + geom_boxplot() + scale_x_discrete(guide = guide_axis_nested()) + coord_flip()

When using the code with ggh4x, the labels are nicely centered in their respective categories, as shown below.

Image

However, the same code used with legendry will cause ticks, as well as tick labels to be (mis)placed to the bottom of their respective categories (for lack of a better word), as shown below.

Image

I was wondering if this behavior of guide_axis_nested() in legendry is intentional or not, and if it is, which argument can be used to place the text in the center of its respective category.

Thanks in advance and best regards!

@teunbrand
Copy link
Owner

Hi, thanks for the report! This appears a duplicate of #61.
The summary of my stance on this is that I'm not going to aim for any sort of coord_flip() compatability.
The coord_flip() function is superseded, and the nested axis works fine if you just swap the x and y aesthetics.

@greengeckoruns
Copy link
Author

Thanks, and thanks for a super-quick feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants