[R] to draw a smooth arc

Greg Snow Greg.Snow at intermountainmail.org
Tue May 1 17:26:09 CEST 2007


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) )

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at intermountainmail.org
(801) 408-8111
 
 

> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch 
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Paulo Barata
> Sent: Monday, April 30, 2007 8:17 PM
> To: r-help at stat.math.ethz.ch
> Subject: [R] to draw a smooth arc
> 
> 
> Dear R-list members,
> 
> I would like to draw a smooth arc. I can draw an arc 
> parametrically, but this produces an arc too coarse, even 
> allowing for different increments in sequence t in the 
> example below. Function "symbols" (graphics) does produce a 
> smooth circle, but it cannot produce an arc.
> 
> Please see the following example, drawing complete circles:
> 
> plot(-5:5,-5:5,type='n')
> ## draws circle with function symbols (package graphics) ## - 
> inner circle is very smooth:
> symbols(0,0,circles=2,add=TRUE)
> ## draws circle parametrically - outer circle is too coarse:
> pi <- 4*atan(1)
> t <- seq(0,2*pi,0.02)
> lines(4*cos(t),4*sin(t))
> 
> Package "plotrix" has a function "draw.arc", but arcs 
> produced with this function are also either too coarse or too 
> polygonal, depending on the number of polygons used to 
> approximate the arc.
> 
> Is there a way to harness the characteristics of function 
> "symbols" (graphics) to draw a smooth arc, not just a complete circle?
> 
> I am using R 2.5.0, running under Windows XP.
> 
> Thank you very much.
> 
> Paulo Barata
> 
> -----------------------------------------------------------------
> Paulo Barata
> Fundacao Oswaldo Cruz (Oswaldo Cruz Foundation) Rua Leopoldo 
> Bulhoes 1480 - 8A 21041-210  Rio de Janeiro - RJ Brazil
> E-mail: pbarata at infolink.com.br
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list