在R图的图例中叠加两个圆圈

时间:2016-04-15 07:41:11

标签: r plot legend

在R中,我可以像......一样编写图例项目。

enter image description here

我将数据绘制为红色点,覆盖红色或橙色外圈,其中这些外圈的大小代表属性,外圈的颜色代表属性。我怎么能在传奇中重复一遍?

enter image description here

到目前为止,我只有传奇......

legend("topleft",
  legend = c("elevation of centerline", "gradient", "boulders", "boulders in steps", "boulders not in steps"),    
  lty=c(1,1,0,0,0), pch=c(NA, NA, 19, 19,19), col=c("black", "gray", "red", "orange", "green"),
  pt.cex=c(0.8, 0.8, 0.8, 2, 2)
)

我试图给第三个元素一个向量,例如

 pch=c(NA, NA, c(19, 19), c(19,19))
没有运气。

2 个答案:

答案 0 :(得分:0)

如果您正在尝试创建"项目A"和"项目B"符号,除了您当前使用的其他pt.bg参数外,还应使用pt.lwdlegend的变体形式(例如ltypch,{{1 }和col)。使用下面的示例并调整代码以查看这些参数如何相互影响:

pt.cex

enter image description here

答案 1 :(得分:0)

我知道这个问题很老,但作为参考,我认为再次调用图例来覆盖红点会更容易。

legend("topleft",
  legend = c("elevation of centerline", "gradient", "boulders in steps", "boulders not in steps"),    
  lty=c(1,1,0,0), pch=c(NA, NA, 19,19), col=c("black", "gray", "orange", "green"),
  pt.cex=c(0.8, 0.8, 2, 2)
)


legend("topleft",
  legend = c("elevation of centerline", "gradient", "boulders in steps", "boulders not in steps"),   
  lty=c(1,1,0,0), pch=c(NA, NA, 19,19), col=c(NA, NA, "red", "red" ),
  pt.cex=c(0.8,0.8,0.8,0.8)
)