R中的图形文本突然变成了斜体



我对R图中的文本有问题。我的代码是

library("ggplot2")
ggplot(df, aes(x = class, y = Proportion)) +
geom_point(aes(color = class)) +
scale_color_viridis_d() +theme_minimal()+
theme(text=element_text(size=16,face = "plain"))

但是,图中的文本为斜体。我加上";face=";"普通";,但没有奏效。我不知道是什么原因,我将感谢你的回答。

face参数有4个选项:纯、斜体、粗体和amp;bold.italic。如果你不想这个数字是斜体的,你可以删除element_text中的face参数,或者你的另一个值"粗体";。

class(df$class)可能被认为是一个因素?

mtcars$cyl <- factor(mtcars$cyl)
library("ggplot2")
ggplot(mtcars, aes(x = cyl, y =mpg)) +
geom_point(aes(color = cyl)) +
scale_color_viridis_d() +theme_minimal()+
theme(text=element_text(size=16,face = "plain"))

最新更新