简体   繁体   中英

R plotrix, polar.plot without discontinuity

I am using the plotrix package to make the polar coordinates from my measurements.

It looks that even when I provide measurements for all the polar cordinates from 1 to 360 degrees (or equally to 0 to 359) the first and last points are not connected. For example

require(plotrix)
polar.plot(seq(1,360),polar.pos=1:360,radial.lim=c(0,361),rp.type="l")

A quick and dirty fix I found was to add one more measurement point, so instead of 360 use 361

as

 polar.plot(seq(1,360),polar.pos=0:360,radial.lim=c(0,361),rp.type="l")

which gives warning messages.

Warning messages:
1: In cos(radial.pos[i, ]) * lengths[i, ] :
  longer object length is not a multiple of shorter object length
2: In sin(radial.pos[i, ]) * lengths[i, ] :
  longer object length is not a multiple of shorter object length

Are there any alternatives since showing my end user warning messages is not something that I like to see :)

I would like to thank you for your reply

Regards Alex

It's going to connect them in order. So, if you want the final vertical line back to the origin, you need to add a datapoint at the end of the vector to make it do so. The error you got is that you added an extra value to one coord but not the other, so x and y are not equal. It recycled one of the vectors to fill it out, which happened to give you what you wanted, but gave you a warning that it was doing so.

polar.plot(c(seq(1,360), 1),
           polar.pos = c(1:360, 1),
           radial.lim = c(0,361),
           rp.type = "l")

在此处输入图片说明

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