1

我正在绘制一个需要绘制图例的情节,并且我需要其中一个是三角形。

  plot.new()
  legend(x=.5,y=.9, c("A","B","C","D"), cex=.8, bty="n", 
         fill = c("green","yellow","red","blue"))

我想legend D变成三角形。我该如何实施?

问候

4

2 回答 2

4

使用pchcol(而不是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))
于 2013-01-18T07:23:33.247 回答
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"))
于 2013-01-18T07:22:56.930 回答