Question

I want to draw a simple polar plot of cos(ang) in R using polar.plot, but the result is a plot with center in (-1) and the resultant plot don't have any sense. For example is not 0 in 90°. How can I solve this problem?

library(plotrix)
grados=seq(0,350,by=10)
radian=grados*pi/180
coseno=cos(radian)  
polar.plot(coseno,grados,rp.type="p")
Était-ce utile?

La solution

I'm not sure that I completely understand your problem, but you should have a look at the help for radial.plot, which explains a lot of the arguments used in polar.plot. In the example below, I add three arguments that may help you set up your plot definitions (start,radial.lim, and clockwise)

polar.plot(coseno,grados, rp.type="p", start=90, radial.lim=c(-1,1.5), clockwise=TRUE)

enter image description here

Autres conseils

Solution;

library(plotrix)
grad=seq(0,359,by=1)
rad=grad*pi/180  # degrees to radian
func=(cos(rad))
func=abs(func)   # negative numbers not plot
polar.plot(func,grad,rp.type="p",radial.lim=c(0,1),
            lwd=2,line.col=4,main="Polar Plot")

enter image description here

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top