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 =” plain”, 但这没用。 我不知道是什么原因 我将不胜感激。

解决方法

face参数具有4个选项:普通,斜体,粗体和bold.italic。 如果您不希望数字为斜体,则可以删除element_text中的face参数或另一个值“ bold”。

,

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"))

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...