[R] to draw a smooth arc

Paulo Barata pbarata at infolink.com.br
Tue May 1 19:29:53 CEST 2007

Dr. Snow and Prof. Ripley,

Dr. Snow's suggestion, using clipplot (package TeachingDemos),
is maybe a partial solution to the problem of drawing an arc of
a circle (as long as the line width of the arc is not that large,
as pointed out by Prof. Ripley). If the arc is symmetrical around
a vertical line, then it is not so difficult to draw it that way.
But an arc that does not have this kind of symmetry would possibly
require some geometrical computations to find the proper rectangle
to be used for clipping.

I would like to suggest that in a future version of R some function
be included in the graphics package to draw smooth arcs with
given center, radius, initial and final angles. I suppose
that the basic ingredients are available in function "symbols"

Thank you very much.

Paulo Barata
(Rio de Janeiro - Brazil)

Prof Brian Ripley wrote:
> On Tue, 1 May 2007, Greg Snow wrote:
>> Here is an approach that clips the circle you like from symbols down to
>> an arc (this will work as long as the arc is less than half a circle,
>> for arcs greater than half a circle, you could draw the whole circle
>> then use this to draw an arc of the bacground color over the section you
>> don't want):
>> library(TeachingDemos)
>> plot(-5:5, -5:5, type='n')
>> clipplot( symbols(0,0,circles=2, add=TRUE), c(0,5), c(0,5) )
> I had considered this approach: clipping a circle to a rectangle isn't 
> strictly an arc, as will be clear if the line width is large.
> Consider
> clipplot(symbols(0, 0 ,circles=2, add=TRUE, lwd=5), c(-1,5), c(-1,5))
> Note too that what happens with clipping is device-dependent.  If R's 
> internal clipping is used, the part-circle is converted to a polygon.

More information about the R-help mailing list