2

This is extension of this question which had a "not possible" answer at that time, but hopefully things change

I set font family and font size via theme

theme_set(theme_minimal(
  base_family="Calibri",
  base_size=8
))

but then I use ggplot with geom_text, geom_text has a life of its own and does not seem to take the font size (at least) from the theme

theme_set(theme_minimal(
  base_size=8
))


df <- data.frame(
  x = c(1, 2, 3), y = c(1, 2, 3), label = c("a", "b", "c")
)

ggplot(df, aes(x, y, label = label)) + geom_text()

enter image description here

m45ha
  • 399
  • 1
  • 9

1 Answers1

2

You can change the default font size for geom_text() using update_geom_defaults().

library(ggplot2) 

theme_set(theme_minimal(
  base_size=8
)) 

update_geom_defaults("text", list(size = 8 / .pt))

ggplot(df, aes(x, y, label = label)) + geom_text()

Note use of the .pt conversion factor to set the size as 8 points rather that 8 mm.

zephryl
  • 14,633
  • 3
  • 11
  • 30