我想更改所有geom_text元素的基本字体。
library(ggplot2)
df <- data.frame(
x = c(1, 2, 3), y = c(1, 2, 3), label = c("a", "b", "c")
)
ggplot(df, aes(x, y, label = label)) + geom_text()
Run Code Online (Sandbox Code Playgroud)
我尝试设置theme文本,但它似乎不影响geom_text元素。
ggplot(df, aes(x, y, label = label)) +
geom_text() +
theme(text = element_text(size = 42))
Run Code Online (Sandbox Code Playgroud)
我看过一些建议使用的旧帖子base_size,但看起来不再支持它。
Suh*_*gde -2
您可以通过在函数内使用它来控制大小geom_text()。
library(ggplot2)
df <- data.frame(
x = c(1, 2, 3), y = c(1, 2, 3), label = c("a", "b", "c")
)
# use 'size' in geom_text function
ggplot(df, aes(x, y, label = label)) +
geom_text(size = 10)
Run Code Online (Sandbox Code Playgroud)