R plot: Displaying both point type and line type in legend
<p>I have generated a plot with <code>plot</code> function. I added the point markers with <code>pch()</code> and the line type with <code>lty</code>. In  the legend section I wanted to merge the points and  lines together. I used <code>merge=TRUE</code> but it didn't work. It is displaying the line type only. The same thing with <code>merge=FALSE</code>. In both cases there is only slight change in the box legend box width. That is it. Any idea?</p>

<p>Here is the sample code:</p>

<pre><code>m&lt;-1:10
n&lt;-runif(1:5)

plot(m,type = "o", col="blue",main = "plot",xlab = "distance",ylab = "height")
lines(n+2,type="o", pch=22,lty=6,col="red")
lines(m-3,type="o", pch=17,lty=5,col="forestgreen")

legend(x=2,y=8,c("R","S","T"),lty=c(1,6,5),pch=c(5,22,17),
       cex=.8, col=c("blue","red","forestgreen"),merge = FALSE)
</code></pre>