如何仅在ggplot中隐藏geom_label的图例?

梅尔

我有一个 ggplot 对象可以按周中的天数绘制结果,如下所示:

ggplot(weekdays, aes(x=weekday, fill=weekday, y=outcome_mean, ymin=outcome_lci, ymax=outcome_uci)) +
  geom_col() +
  geom_errorbar() +
  theme_bw() +
  geom_label(aes(label=paste(visits, "Visits", sep=" ")), y=-0.75, size=3.5, color="black", fontface="bold") +
labs(y="Outcome Mean", x="Weekday", title = "Outcome by Weekday", fill="Weekday:") +
  theme(panel.grid.minor = element_line(colour="lightgrey", size=0.5)) +
  theme(panel.grid.major = element_line(colour="lightgrey", size=0.5)) +
  theme(axis.text.x = element_text(face="bold", size=10)) +
  theme(axis.text.y = element_text(face="bold", size=12)) +
  theme(axis.title.x = element_text(face="bold", size=16)) +
  theme(axis.title.y = element_text(face="bold", size=16)) +
  theme(legend.text= element_text(face="bold", size=12)) +
  theme(legend.title= element_text(face="bold", size=14)) +
  theme(plot.title= element_text(face="bold", size=16, hjust=0.5)) +
  #scale_label(guide=FALSE) +
  scale_y_continuous(limits=c(-1,20), breaks= seq(0,30,2), minor_breaks=seq(0,30,1)) 

这使:

ggplot 图的图像

但是我不喜欢填充图例中的小“a”符号,如何在不隐藏整个图例的情况下摆脱这些符号(因为在我的一些图中 x 和填充是不同的变量,所以我需要保留填充传奇)?

我曾尝试添加“scale_label(guide=FALSE)”(如上文注释所示),但这不是公认的功能。

有谁知道我如何实现这一目标?

杰克布鲁克斯
...
geom_label(..., show.legend = FALSE) +
...

https://ggplot2.tidyverse.org/reference/geom_text.html

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何在ggplot2中隐藏图表图例?

ggplot2 1.01中没有更多的geom_label()吗?

在R中的ggplot2的geom_label的pdf输出中摆脱边界

geom_label中的上标星号

如何在R ggplot的geom_label框中居中放置文本?

如何在geom_label中使用angle?

如何将bquote与ggplot2 geom_label结合使用?

ggplot2中基于`.count..`变量的`geom_label`的y值

ggplot更改图例中的geom顺序

如何在ggplot的geom_label中设置标准标签大小?

fill参数使geom_label()中的位置参数无效

在ggplot2中为geom_label设置“基本大小”,以便仍可读取最小值

geom_label不会按比例缩放以在Shiny中绘图

如何使用geom_label指示位置

在geom_label()中打印..count ..值

将ggplot geom_label定位为轴限制的比例

ggplot从图例中删除geom_label边框

ggplot2-如何替换图例中的geom符号?

如何添加相对于geom_point大小的位置的geom_text或geom_label?

如何使用ggplot2中的geom_pointrange()自动消除线型图例的形状和图例的线型?

geom_label_repel 和 geom_label 的错误图例

如何添加缺失的美学:标签到 geom_label()

使用ggplot将geom_label定位在网络外部?

使用 \n 换行时,在 geom_label() 和 geom_text() 中减少 R ggplot 中的行高

在ggplot中隐藏特定的图例条目

如何将 geom_label 放入 geom_bar

自定义图例,引入未绘制但通过 geom_label 汇总的变量

geom_label 中的下标

修复 ggplot 中 `geom_label` 的垂直位置