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 updating ggplot2 functions xlab/ylab --> labs() #520

Closed
sjspielman opened this issue Feb 25, 2022 · 7 comments
Closed

Consider updating ggplot2 functions xlab/ylab --> labs() #520

sjspielman opened this issue Feb 25, 2022 · 7 comments

Comments

@sjspielman
Copy link
Member

Currently, we teach separate xlab, ylab, and ggtitle functions. I very strongly recommend we update materials to use the overall function labs(), which can take args like..

labs(
  x = "my x-axis title", 
  y = "my y title",
  title = "plot title",
  ## and more!!!
  caption = "people sometimes like to put author/credit here",
  subtitle = "oooh subtitle"
)

I think this is also small enough to pretty easily accomplish before March 2022, if there is interest in this minor update.

@jashapiro
Copy link
Member

I don't have a problem with this, but just a caution that it may be a bit bigger than it appears at first. If we replace all of the code we have, we will need to make this change in all training modules (not just intro), and in all exercise notebooks, and make sure we update the cheat sheets.

Another option, which I might prefer, is to keep xlab() and ylab() (no named arguments can be nice) introduced first, and then present labs() as an option to consolidate text labels as plots get more complex.

One very nice thing about labs() that I think would be very nice to include is that it makes it much more straightforward to change the labels of legends (this is much more important to me than subtitles, because I don't generally like titles for scientific plots, especially not baked into the image).

@sjspielman
Copy link
Member Author

sjspielman commented Feb 28, 2022

it makes it much more straightforward to change the labels of legends

^ This is a huge benefit.

I definitely see how it is a bigger task than it appears at first, since labeling figures is of course a common activity in ~every day's notebook.

What you propose about adding in labs() would probably require a small addition to the {ggplot2} training notebook to explain differences and show examples:

  • Same plot made with xlab()/ylab() vs labs()
  • Example of changing legend title

Then, in other notebooks, we add a sentence here and there like "you can also use labs() if you prefer!" or similar.

@sjspielman
Copy link
Member Author

It also seems that labs() is already being fully used instead of other labeling functions in pathway-analysis and machine-learning modules.
But, the RNA-seq module goes back and forth, with one file using <x/y>lab() and another using labs().

@jaclyn-taroni
Copy link
Member

It also seems that labs() is already being fully used instead of other labeling functions in pathway-analysis and machine-learning modules.
But, the RNA-seq module goes back and forth, with one file using <x/y>lab() and another using labs().

All of those modules are not going to be relevant for this training, FWIW.

@jashapiro
Copy link
Member

Given the above, I think it definitely makes sense to introduce labs() in the ggplot module (and add it to the cheat sheet). If we want to update other modules to use it, I think we can do that where it seems to make sense. I would not worry about adding comments everywhere.

@sjspielman
Copy link
Member Author

Tagging @cbethell as our {ggplot2} teacher, FYI!

@sjspielman
Copy link
Member Author

Closed with #522.

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

No branches or pull requests

3 participants