r - 使用 ggplot 隐藏图例

标签 r ggplot2

<分区>

假设我有

ggplot(data=PlantGrowth, aes(x=group, y=weight, fill=group)) + geom_boxplot()

而且我不想显示图例。从图中隐藏或删除图例的最简单方法是什么?

最佳答案

添加主题(legend.position="none"),像这样:

ggplot(data=PlantGrowth, aes(x=group, y=weight, fill=group)) + 
  geom_boxplot() + 
  theme(legend.position="none")

( source )

关于r - 使用 ggplot 隐藏图例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23682371/

相关文章:

r - 编写函数来替换 R 中的 for 循环

在 R 中创建新列时通过变量名引用数据框

r - ggtitle : remove extra spaces and add a new line in ggplot title 中的粘贴函数

r - 在 geom_bar 中按类别定义不同的标签大小

r - 带 l 的 ggplot map

r - R中同一窗口中的多个不同大小的图?

r:在 ggplot2 中绘制带孔的多边形时撕裂

r - 移动到 RStudio 中的匹配大括号

javascript - R Shiny sliderInput 按钮 ---> 页面打开时动画

r - R 中的++ 运算符