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

最佳答案

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


(您必须仔细看一下才能看到区别,尤其是“对接”和“方形”帽之间的差异)

08-24 18:31