2011-12-12 5 views

答えて

3

:点の少なくとも一方がの境界になること

r <- 3*runif(10) 
degs <- 360*runif(10) 

# First you want to convert the degrees to radians 

theta <- 2*pi*degs/360 

# Plot your points by converting to cartesian 

plot(r*sin(theta),r*cos(theta),xlim=c(-max(r),max(r)),ylim=c(-max(r),max(r))) 

# Add a circle around the points 

polygon(max(r)*sin(seq(0,2*pi,length.out=100)),max(r)*cos(seq(0,2*pi,length.out=100))) 

注あなたがこれを望んでいなければ、あなたはmax(r)文章のようなもの1.1*max(r)

+0

brilliantに変更された場合に機能します!私はそのおかげで仕事をすることができます。 – wbarksdale

+1

'、asp = 1'をplot文に追加して、最終イメージが楕円の代わりに円として表示されるようにします。 –

0

極座標系を使用してください(link to wiki)。 (link

、その後COORDSをスクリーニングするために翻訳し、その後

デカルト座標系へtransleそれは

+0

例を与えることは何度も最高の教えです。 – Rodrigo

2

ggplot2でこれを行うには、あなたがする必要がある(例えば、0,0については、モニターの中心です) coord_polarを使用すると、ggplot2がすべての変換を行います。コードの例:基地グラフィックで

library(ggplot2) 
# I use the builtin dataset 'cars' 
# Normal points plot 
ggplot(aes(x = speed, y = dist), data = cars) + geom_point() 

enter image description here

# With polar coordinates 
ggplot(aes(x = speed, y = dist), data = cars) + geom_point() + 
    coord_polar(theta = "dist") 

enter image description here

+0

これは完璧に見えますが、match.arg(theta、c( "x"、 "y"))のエラー: "arg"は "x"、 "y"のいずれかでなければなりません – wbarksdale

+0

問題これは私が度で位置を指定することができないということです – wbarksdale

+0

ポイントのフィードバックをもっとしたい場合は、再現可能な例を投稿してください。 –

関連する問題