ggeasy icon indicating copy to clipboard operation
ggeasy copied to clipboard

Feature request: `easy_plot_title_face` etc to easily make titles bold

Open davidhodge931 opened this issue 1 year ago • 8 comments
trafficstars

It'd be cool to be able to easily make the title bold etc

easy_plot_title_face(face = NULL, teach = FALSE)

easy_plot_subtitle_face(face = NULL, teach = FALSE)

easy_plot_caption_face(face = NULL, teach = FALSE)

davidhodge931 avatar Dec 17 '23 04:12 davidhodge931

I think we already have this support!

library(ggplot2)
library(ggeasy)
ggplot(mtcars, aes(mpg, hp)) +
  geom_point() + 
  labs(title = "Plot Title in Bold", subtitle = "subtitle in regular font") +
  easy_change_text("plot.title", "face", "bold")


ggplot(mtcars, aes(mpg, hp)) +
  geom_point() + 
  labs(title = "Plot Title in regular font", subtitle = "subtitle in bold") +
  easy_change_text("plot.subtitle", "face", "bold")

Created on 2023-12-17 with reprex v2.0.2

jonocarroll avatar Dec 17 '23 04:12 jonocarroll

Oh great, thanks!

davidhodge931 avatar Dec 17 '23 05:12 davidhodge931

Actually, do you think we could have this for just making the plot title bold, as this is a super common thing to have to do?

ggeasy::easy_plot_title_bold()

Having a single function to do this would make it way easier

davidhodge931 avatar Dec 20 '23 20:12 davidhodge931

We could add that, just a simple wrapper of my suggestion above. Maybe a shortcut for italic subtitle. Any others?

jonocarroll avatar Dec 21 '23 04:12 jonocarroll

Thanks!

Bold title is the only one I would use, I think. I tend to have everything else plain, including the subtitle

davidhodge931 avatar Dec 21 '23 04:12 davidhodge931

Actually ggeasy::easy_plot_title_plain() would be super useful too, as my theme defaults to bold - but sometimes you want it to be plain (e.g. when you are patching plots together)

davidhodge931 avatar Feb 01 '24 03:02 davidhodge931

I think both of these are just straightforward aliases we can define

library(ggplot2)
library(ggeasy)
p <- ggplot(mtcars, aes(mpg, hp)) +
  geom_point() + 
  labs(title = "Plot Title", subtitle = "subtitle") 
p


boldp <- p + theme(text = element_text(face = "bold"))
boldp 

 
easy_plot_title_bold <- function() {
  easy_change_text("plot.title", "face", "bold")
}

easy_plot_title_plain <- function() {
  easy_change_text("plot.title", "face", "plain")
}

p + easy_plot_title_bold()

boldp + easy_plot_title_plain()

Created on 2024-02-01 with reprex v2.0.2

jonocarroll avatar Feb 01 '24 03:02 jonocarroll

Looks great @jonocarroll

Very very useful :)

davidhodge931 avatar Feb 01 '24 04:02 davidhodge931