将绘制的段末端从圆形变为平坦

时间:2012-06-08 00:23:24

标签: r

当我使用segments()使用R绘制线段时,末端始终显示为圆形。如何将两端更改为扁平?

1 个答案:

答案 0 :(得分:14)

来自?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.

例如:

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)

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

(你必须仔细看看差异,特别是“屁股”和“方形”帽之间的差异)