我正在绘制一个需要绘制图例的情节,并且我需要其中一个是三角形。
plot.new()
legend(x=.5,y=.9, c("A","B","C","D"), cex=.8, bty="n",
fill = c("green","yellow","red","blue"))
我想legend D
变成三角形。我该如何实施?
问候
使用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))
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"))