-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Description
Hi!
I've encountered a strange phenomenon. It seems that after users manually add fonts, the theme(text=element_text())
properties no longer control the font in geom_text
.
library(ggplot2)
library(showtext)
#> Loading required package: sysfonts
#> Loading required package: showtextdb
font_add("Times New Roman", "/Library/Fonts/Times New Roman.ttf")
showtext_auto()
data <- data.frame(
x = 1:5,
y = c(2, 4, 6, 8, 10),
label = c("one", "two", "three", "four", "five")
)
ggplot(data, aes(x = x, y = y, label = label)) +
geom_point(size = 3) +
geom_text(size = 8, vjust = -1) + # No font specified for use
labs(title = 'Times New Roman') +
theme(text = element_text(family = "Times New Roman", angle = 45))
After directly specifying the font family with geom_text(family = “Times New Roman”)
, font family works as expected. But angle
still not effective.
ggplot(data, aes(x = x, y = y, label = label)) +
geom_point(size = 3) +
geom_text(size = 8, vjust = -1, family = "Times New Roman") +
labs(title = 'Times New Roman') +
theme(text = element_text(family = "Times New Roman", angle = 45))
Created on 2025-10-13 with reprex v2.1.1
AND, I haven't tested whether this issue occurs with the built-in fonts.
Metadata
Metadata
Assignees
Labels
No labels