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

Consider adding code for rotating the y-axis label using the title. #60

Open
iamstein opened this issue Apr 12, 2023 · 3 comments
Open
Assignees

Comments

@iamstein
Copy link
Member

From Andrew Wright

image

@iamstein
Copy link
Member Author

Here's another way to do it. And actually, it just takes one command (theme), so maybe it's not worth a separate xgx function, though it might be easier to remember to type xgx_ylab_horiz("label") than the two lines it takes to call both ylab and remember all the theme/element code. It does scrunch the graph a little bit, but I think it's nicer than using the title option because it would be less confusing.

library(ggplot2)
ggplot(mtcars, aes(wt, mpg)) + 
  geom_point() + 
  ylab("First line \nSecond Line") + 
  theme(axis.title.y = element_text(angle = 0, vjust = 1))

image

@iamstein
Copy link
Member Author

To make sure users don't have a horizontal ylabel that is too long, we could do some string checking and manipulation, so if the ylabel is really long, we could figure out a reasonable way to insert “\n” characters. And there could be a default “maximum character length” option of say 20, that the user can tweak, or just make their own custom string with “\n”s where they want. I bet there’s even some R function or other for splitting strings in a smart way we may or may not want to use.

@iamstein
Copy link
Member Author

This really only would reduce code from 2 lines to 1 line, it's not a big advantage, so we won't make this high priority

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

4 participants