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應該給你的東西。 –