使用ggplot2更改字体

问题描述 投票:0回答:1

我正在使用 R 并尝试在 ggplot2 中制作图表。下面您可以看到我的数据和图表。

df <- data.frame(
  variable = c("USA", "CAN", "GBR"),
  value = c(10, 15, 20)
)

   ggplot(df, aes(x = value, y = reorder(variable, value), fill = variable)) +
                geom_bar(stat = "identity", width = 0.5) +
                labs(title = " ", x = "  In percent ", y = "") +
                theme_minimal() +
                theme(legend.position = "none")

enter image description here

当我创建此图表时,我注意到 x 轴上的值和标题上的值之间存在差异。具体来说,这些值以灰色显示,当我将它们插入 Word 时不容易读取。另一方面,标题是黑色的,更具可读性。谁能帮我弄清楚如何使 x 轴上的值显示为与标题相同的黑色?

r ggplot2
1个回答
0
投票

axis.text.x = element_text(colour = 'black'))
添加到
theme(...)

© www.soinside.com 2019 - 2024. All rights reserved.