[R] how to draw pentagon?

Jim Lemon jim at bitwrit.com.au
Tue Aug 18 13:08:18 CEST 2009


Hemavathi Ramulu wrote:
> Hi everyone,
> I want you all help me to give an idea, how to draw pentagon with points?
> Maybe can use function, but I'm stuck.
>
> Yhank you.
>
>   
Hi Hemavathi,
Try these to draw, successively, points at the vertices of a pentagon, 
the outline of a pentagon and a filled pentagon. To rotate the pentagon, 
add the rotation in radians to the two sequences.

xpos<-cos(seq(0,2*pi,by=2*pi/5))
ypos<-sin(seq(0,2*pi,by=2*pi/5))
plot(xpos,ypos,pty="s")
lines(xpos,ypos)
polygon(xpos,ypos,col="red")

Jim




More information about the R-help mailing list