These functions can be used to change the font of all text elements in any themes. Additionally, all font weights (or faces) of the given theme will be set appropriately to ensure readability, e.g., setting title font to be bold.
Arguments
- ret
A
ggplot2::theme()
object- font_family_name
The name of the font
Note
Due to limitation of
extrafont
and the format of SF Pro,sf_set_sf_pro()
is not yet available, and SF Pro does not work as expected.
Examples
if (FALSE) {
library(ggplot2)
ggplot(mtcars) +
geom_point(aes(x = wt, y = mpg, colour = factor(gear))) +
labs(title = "Fuel Economy",
subtitle = "Fuel economy declines as weight increases, 1973-74",
caption = "Data from the 1974 Motor Trend US magazine.",
x = "Weight (1000 lbs)",
y = "MPG",
colour = "Gears") +
facet_grid(vs ~ am) +
sf_set_inter(theme_linedraw()) +
scale_colour_ios_light()
}
if (FALSE) {
library(ggplot2)
ggplot(mtcars) +
geom_point(aes(x = wt, y = mpg, colour = factor(gear))) +
labs(title = "Fuel Economy",
subtitle = "Fuel economy declines as weight increases, 1973-74",
caption = "Data from the 1974 Motor Trend US magazine.",
x = "Weight (1000 lbs)",
y = "MPG",
colour = "Gears") +
facet_grid(vs ~ am) +
sf_set_custom_font(theme_linedraw(), "Gill Sans") +
scale_colour_ios_light()
}