Reputation: 81
This post was great to set a base size for all my plots in R Markdown docs, which I usually work in (e.g., theme_set(theme_grey(base_size = 18))
. However, as someone eluded to in the comments, geom_text()
does not inherit theme_set()
. Have any suggestions?
I am open to completely different ideas for managing font size in ggplot plots in R Markdown. FYI, I usually knit to Word and then upload to Google Drive.
Upvotes: 2
Views: 1551
Reputation: 48251
geom_text
indeed doesn't inherit theme_set()
. See here how we have size = 3.88
set directly. However, the same source code suggests to use the following.
GeomText$default_aes$size <- 1
ggplot(mtcars, aes(wt, mpg, label = rownames(mtcars))) + geom_text()
Now this works only for geom_text
, but I don't think it's a good idea to set the same size for every single thing anyway (axes text, titles, etc.). However, it seems to be analogous with others geoms, e.g.,
GeomLabel$default_aes$size
# [1] 3.88
Update: there seems to exist a formal function doing basically the same:
update_geom_defaults("text", list(size = 10))
Upvotes: 3