简体   繁体   中英

Polar plot coordinates are wrong

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

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)

在此处输入图片说明

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

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM