Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Longer lines in legend()

Tags:

graph

plot

r

legend

I have a

plot(1,1)
legend("bottomleft", c("A","B","C"), lwd=3, bty="n",lty=c(1,3,4))

Is it possible to make the lines in the legend longer (base R only please)? It seems a bit difficult to immediately see the difference of lty=3 and lty=4 in the legend when the lines are so short. Increasing the lwd does not help either.

Thanks a lot

like image 303
ECII Avatar asked Apr 22 '12 11:04

ECII


People also ask

How do I make my legend longer in R?

To change the legend size of the plot, the user needs to use the cex argument of the legend function and specify its value with the user requirement, the values of cex greater than 1 will increase the legend size in the plot and the value of cex less than 1 will decrease the size of the legend in the plot.

How do I change the length of a line in Matlab?

Direct link to this commentItemTokenSize = [x1,x2]; By default x1=30 and x2=18 so put larger or smaller numbers as x1,x2 to increase or decrease the legend line size.


1 Answers

You can set the seg.len argument.

plot(1,1)
legend("bottomleft", 
  c("A","B","C"), 
  lwd=3, bty="n",lty=c(1,3,4),
  seg.len=5
)
like image 163
Vincent Zoonekynd Avatar answered Sep 17 '22 13:09

Vincent Zoonekynd