library(ggplot2)
p <- ggplot(mtcars) +
geom_point(
aes(
x = mpg,
y = hp
)
) +
labs(
x = "Miles per gallon",
y = "Horsepower",
title = "Horsepower relative to miles per gallon"
)
# the default font is source sans 3
# an error will occur if not loaded before using theme_hdx()
try(p + theme_hdx())
# you can change the base family
p + theme_hdx(base_family = "sans")
# or load Source Sans 3 using gghdx() or load_source_sans_3()
load_source_sans_3()
p + theme_hdx()
# we can change the axis line direction depending on the plot
p + theme_hdx(horizontal = FALSE)
Run the code above in your browser using DataLab