Hi there,
Do you know how can I change the default font used for all text (title, caption, xytitle, xylabel, etc) in ggplot? I have a script plotting different types of figures using ggplot via different utility plot fuctions. I know I can specify font in the theme(), but I will have to change it in every plot function. Is there a way to specify the font globally at the begninging of the script and it will be applied to all ggplot?
Thanks a lot.
I've used quartzFonts():
quartzFonts(
serif = quartzFont(
c(
"Times-Roman",
"Times-Bold",
"Times-Italic",
"Times-BoldItalic"
)),
sans = quartzFont(
c(
"Helvetica-BoldOblique",
"Helvetica-BoldOblique",
"Helvetica-BoldOblique",
"Helvetica-BoldOblique"
)
),
mono = quartzFont(
c("Courier",
"Courier-Bold",
"Courier-Oblique",
"Courier-BoldOblique"
)
)
)
ggplot()+
annotate("text", x = 0, y = 0, label = "Hello!", family = "mono", fontface = "italic", size = 20)
Thanks a lot @mduvekot. This doesn’t answer my question as I will still have to assign family in the theme.
You can set your default theme to use a specific font choice, so that every plot you make uses it, even without specifying the font. See ?theme_set() and related functions.
No you don’t. The sans will be the default.