2

次の極座標プロットの例を検討してください。

library(plotrix)
testlen <- c(rnorm(36)*2 + 5)
testpos <- seq(0, 350, by = 10)
polar.plot(testlen, testpos, main = "Test Polar Plot",
           lwd = 3, line.col = 4, rp.type = "s")

出力

角度 30 と 330、および 150 と 210 (中心から外側) に線を追加したいと思います。line 関数を試してみましたが、うまくいきませんでした。

4

2 に答える 2

2

正確な配置の計算は少しばかげていますが、テストデータを使用しています

set.seed(15)
testlen<-c(rnorm(36)*2+5)
testpos<-seq(0,350,by=10)
polar.plot(testlen,testpos,main="Test Polar Plot",
    lwd=3,line.col=4,rp.type="s")

20,150,210,300 で行を追加できます

add.line <- c(30,330, 150,210)/360*2*pi
maxlength <- max(pretty(range(testlen)))-min(testlen)
segments(0, 0, cos(add.line) * maxlength, sin(add.line) * maxlength, 
    col = "red")

そして、それは次のプロットになります

極座標プロットで強調表示された角度

于 2014-06-02T14:47:21.680 に答える
1

rp.type = "r"引数とのみを使用できますadd = TRUE。だから、次のようなもの

library(plotrix)
set.seed(1)
testlen <- c(rnorm(36)*2 + 5)
testpos <- seq(0,350, by = 10)
polar.plot(testlen, testpos, main = "Test Polar Plot",
           lwd = 3, line.col = 4, rp.type = "s")

に続く

pos <- c(30, 330, 150, 210)
len <- c(10, 10, 10, 10)
polar.plot(lengths = len, polar.pos = pos, 
           radial.lim = c(0, 15),
           lwd = 2, line.col = 2, rp.type = "r", add = TRUE)

目的の出力が得られます。

出力

于 2014-06-02T14:47:57.330 に答える