我正在制作一个我需要绘制图例的情节,我要求其中一个是三角形。
plot.new()
legend(x=.5,y=.9, c("A","B","C","D"), cex=.8, bty="n",
fill = c("green","yellow","red","blue"))
我希望legend D
成为三角形。我该如何实现呢?
此致
答案 0 :(得分:4)
使用pch
和col
(而不是fill
):
plot.new()
legend(x=.5,y=.9, c("A","B","C","D"), cex=.8, bty="n",
col=c("green", "yellow", "red", "blue"), pch=c(15, 15, 15, 17))
答案 1 :(得分:2)
pch参数选择图例符号的形状:
plot.new();
legend(x=.5,y=.9, c("A","B","C","D"),
pch=c(1,4,3,2), cex=.8, bty="n",
col=c("green","yellow","red","blue"))