Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

change plotted segment ends from round to flat

Tags:

r

When i use segments() to draw a segment using R, the ends always appear rounded. How can I change the ends to flat?

like image 942
Yuting Avatar asked Jun 08 '12 00:06

Yuting


1 Answers

From ?par:

 ‘lend’ The line end style.  This can be specified as an integer or
      string:

      ‘0’ and ‘"round"’ mean rounded line caps [_default_];

      ‘1’ and ‘"butt"’ mean butt line caps;

      ‘2’ and ‘"square"’ mean square line caps.

For example:

plot(0:1,0:1,type="n")
par(lend=0); segments(0,0.2,1,0.2,lwd=8)
par(lend=1); segments(0,0.4,1,0.4,lwd=8)
par(lend=2); segments(0,0.6,1,0.6,lwd=8)

or segments(0,0.2,1,0.2,lwd=8, lend=1) etc. enter image description here

(You have to look pretty carefully to see the difference, especially between "butt" and "square" caps)

like image 196
Ben Bolker Avatar answered Sep 21 '22 12:09

Ben Bolker