change plotted segment ends from round to flat

前端 未结 1 594
一向
一向 2021-01-04 11:40

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

相关标签:
1条回答
  • 2021-01-04 11:49

    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)

    0 讨论(0)
提交回复
热议问题