我正在用 ggplot2 绘制线条,如下所示:
ggplot(iris, aes(Petal.Width,Petal.Length,color=Species)) + geom_line() + theme_bw()
.
我发现图例标记很小,所以我希望它们更大。如果我改变大小,情节上的线条也会改变:
ggplot(iris, aes(Petal.Width,Petal.Length,color=Species)) + geom_line(size=4) + theme_bw()
.
但我只想看到传说中的粗线,我希望情节上的线条细。我尝试使用legend.key.size
,但它改变了标记的正方形,而不是线的宽度:
library(grid) # for unit
ggplot(iris,aes(Petal.Width,Petal.Length,color=Species))+geom_line()+theme_bw() + theme(legend.key.size=unit(1,"cm"))
我也尝试使用积分:
ggplot(iris,aes(Petal.Width,Petal.Length,color=Species)) + geom_line() + geom_point(size=4) + theme_bw()
但当然它仍然会影响情节和传说:
我想用线来作图,用点/点来作图例。
所以我要问两件事:
- 如何在不改变情节的情况下改变图例中的线宽?
- 如何在情节中画线,但在图例中画点/点/正方形?