R-更改ggplot2中的形状图例geom_col

问题描述

我正在尝试更改geom_col图的图例形状。默认情况下,图例是正方形,我想更改为圆形(或三角形或其他形状)。由于颜色由fill控制,因此我认为覆盖此参数应该可以解决问题:

library(ggplot2)
data("Titanic")
Titanic <- as.data.frame(Titanic)

ggplot(data = Titanic,aes(x = Class,y = Freq,fill = Survived)) + geom_col() +
   guides(fill = guide_legend(override.aes = list(shape = 16))) 

我也想更加具体

ggplot(data = Titanic,fill = Survived)) + geom_col() +
  scale_shape_manual(values = c("No" = 16,"Yes" = 17)) 

但传说并没有改变。有什么建议吗?

(我确实看过相关问题Capture of the html inspector,但似乎也不起作用。我想是因为没有使用geom_point吗?)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)