-
Notifications
You must be signed in to change notification settings - Fork 11
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
Repeating only x axis? #31
Comments
Thank you for your kind words.
Your request is unfortunately not supported. I did not consider that
feature to be relevant at the time. I am actually curious what your
particular case is, where this is desirable.
I can offer some suggestions on how to solve it:
1) If y-axes are the same throughout all facets, but the x-axes change, you
could simply use facet_wrap(scales="free_x").
2) Use facet_ret_grid as it is now, and then remove the unwanted y-axis
grobs.
Take a look at the vignette
https://cran.r-project.org/web/packages/lemon/vignettes/gtable_show_lemonade.html
You will need to render the ggplot2-object with ggplotGrob (this is what
printing the ggplot2-object actually does):
p <- ggplot(...)
g <- ggplotGrob(p)
Use the function gtable_show_names to find the names of the grobs and find
their position (rownumber) in the layout-table (g$layout).
Replace these positions in g$grobs with zeroGrob().
Finally (optional), reduce the spacing induced by the y-axes.
Behind the scene, the ggplot-grob positions all the plot's elements (title,
axis, plot-area) in a grid. This is what g$layout describes.
Find the names of the axis-components in g$layout, and take note of their
left-coordinate (the `l`-column).
The widths of each column is stored in g$widths, ordered left to right.
Replace the relevant positions with unit(0, "npc").
You then print with
grid::grid.newpage()
grid::grid.draw(g)
Kind, Stefan
Den tirs. 22. aug. 2023 kl. 03.05 skrev Teng Gao ***@***.***>:
… Hi,
Thanks for the useful package. How do I only repeat x axis in
facet_rep_grid but not y?
—
Reply to this email directly, view it on GitHub
<#31>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA3NBGXXF2QOXIZDDPMSOFDXWQAUNANCNFSM6AAAAAA3ZER2PU>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
Thanks for the useful package. How do I only repeat x axis in facet_rep_grid but not y?
The text was updated successfully, but these errors were encountered: