-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Horizontal y axis title above plot, left-justified #6495
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
Comments
Thanks for the suggestion! This would be the perview of |
Hmm these are really interesting questions! Just dabbling with those just now, my hot takes would be:
So, I'm envisioning something like: I suppose this means a "bottom" option would be needed along with a "top".
So, I'd probably do: Not the best example but hopefully gets the point across. Otherwise, I guess I'd be envisioning this: If the strip backgrounds could be moved up too (I had to suppress them in that last one). ...Yes, definitely a few intersection points here for sure! |
Thanks for your thoughts on this! I do think it is something that is nice to have, I'm just not quite convinced it belongs in base ggplot2. To my mind, this is the kind of feature an extension package could support. If you don't want to write your own, I think I might find a place for it in ggh4x if you'd like. |
It might not belong in base ggplot2--that's true! However, FWIW, I have code I adapted from the accepted answer on the SO post linked to above that I think works quite well. I'll paste it here in case it's useful:
Full disclosure: I do use ChatGPT to troubleshoot/tinker, so some of this code is likely from ChatGPT but I verified and annotated it line by line--so far as I can tell, it is doing what it says on the tin :). But I'm no expert! |
A lot of design guides argue that text should, as often as possible, be printed horizontally to align with how most humans naturally read. However, the default y-axis title in ggplot2 (and pretty much every software ever!) is vertical. This makes sense, but I do actually much prefer the aesthetic of the y-axis title being horizontal and left-justified above the plot, as summarized in my SO post here: https://stackoverflow.com/questions/79654995/in-ggplot2-in-r-how-should-i-position-a-y-axis-title-in-the-top-plot-margin-le
As I noted there, there are several "hack-y" ways to do this, but none that "just work" programmatically out of the box.
What I'd love to see is something akin to the legend.position theme element but for the y axis title. If I could just do y.axis.title.position = "top", where hjust could then be used to slide it to one edge or the other, that'd be awesome! I don't presume to know any of the technical difficulties of implementing that though....
The text was updated successfully, but these errors were encountered: