1
我想使用文本几何图形修改ggplot2中的图例。示例如下所示。我想将a改为点(圆圈),而不是1,2,3使用自定义名称,如低,中,高。任何建议将不胜感激。修改文本图例ggplot2
示例数据:
x y Freq colors
1 -2 32 2 1
2 -2 36 1 1
3 -2 37 1 1
4 -2 40 2 1
5 -1 32 2 1
6 0 29 2 1
代码:
fit=ggplot(a1,aes(x,y,color=factor(colors)),col=colors)+
geom_text(aes(label=Freq),size=5)+
theme_bw()+
opts(legend.position='top',
legend.title=theme_blank(),
legend.key=theme_rect(fill="white",colour="white"))
print(fit)
本页[(R Cookbook)](http://wiki.stdout.org/rcookbook/Graphs/Legends%20(ggplot2)/)对定制legen的东西进行了大量讨论。结合这篇文章:http://stackoverflow.com/questions/10405823/changing-the-symbol-in-the-legend-key-in-ggplot2应该给你的东西。 –