rplotpch

how to define predefined pch values and new pch shape in same R code


I am trying to put different shape using pch. but it's not giving expected output.

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)
             )

Expected output should be : - Upper limit, 0(pch=19) Estimated, - Lower limit but the actual output is: -Upper limit, 1 estimated, - Lower Limit. enter image description here


Solution

  • You might be looking for 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