Reputation: 1389
I'm creating a chart and want to change the font for the title and subtitle.
I would like the title to be Futura bold and the subtitle to be Futura plain.
# Get the mtcars dataset to create some example plots
data(mtcars)
df <- mtcars[, c("mpg", "cyl", "wt")]
# Convert cyl to a factor variable
df$cyl <- as.factor(df$cyl)
# Plot
ggplot(data = mtcars, aes(x = wt, y = mpg)) +
geom_point() +
ggtitle('Basic Scatter Chart', subtitle = 'New ggplot theme') +
theme(
# Set title
plot.title = ggplot2::element_text(family='Futura',
size=20,
face='bold',
color="#222222"),
plot.subtitle = ggplot2::element_text(family= 'Futura',
face='plain',
size=16,
margin=ggplot2::margin(9,0,9,0)))
This gives me the following error:
Error in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
polygon edge not found
In addition: Warning messages:
1: In grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
no font could be found for family "Futura"
2: In grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
no font could be found for family "Futura"
If I change the face argument from plain to bold, then the plot works, so it seems as though R can't find the plain variant of the Futura font. When I look in font book, I can see medium, medium italic, bold.
For other fonts that work with the face plain (e.g. Helvetica), they have a regular variant in font book.
How to I rectify this issue to get a plain variant of Futura to work? Can I not just assign medium to plain in R?
Upvotes: 1
Views: 1937