如何在同一R代码中定义预定义的pch值和新的pch形状

时间:2019-04-12 02:14:39

标签: r plot pch

我正在尝试使用pch放置其他形状。但是没有给出预期的输出。

legend("topleft",
             legend = c("Upper limit ","Estimated","Lower limit"), 
             col = c("black","black","black"), 
             pch = c('-','19','-'), 
             #bty="n",
             cex=1.2,
             text.col="black",
             horiz=F,
             inset=c(0.1,0.1)
             )

预期输出应为: -上限, 0(pch = 19)估计, -下限 但实际输出是: -上限 估计1个, -下限。 enter image description here

1 个答案:

答案 0 :(得分:2)

您可能正在寻找lty

plot(1:10, type="n")
legend("topleft", legend=c("Upper limit ", "Estimated", "Lower limit"), 
       pch=c(NA, 19, NA), lty=c(1, NA, 1), cex=1.2, inset=c(0.1, 0.1))

enter image description here