如何在 R 中使用 ggplot2 更改图例类型?
我按组使用 geom_area()
创建了一个图表。图例的形状是正方形。我希望它是一条线,所以没有任何关于我用于填充美学的比例的信息。我怎样才能做到这一点?
Ps:guides(override.aes())
没有帮助,因为它只允许我更改我放入美学中的信息,而不是乘坐fill
。
I created a graph using geom_area()
by group. The shape of the legend is a square. I would like it to be a line, so without any information regarding the scale I use for the fill
aesthetic. How can I achieve that ?
Ps : guides(override.aes())
is not helpful since it only allows me to change the informations I put in my aesthetics, not to get ride of fill
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
目前尚不清楚为什么您想要一个与绘图无关的图例,但您可以使用
key_glyph
参数更改键字形。您可能想使用override.aes将该区域的线条颜色更改为黑色。It's not clear why you want a legend that doesn't relate to the plot, but you can change the key glyph using the
key_glyph
parameter. You probably want to useoverride.aes
to change the line colour of the area to black.