2017-04-13 18 views
0

私はこれらの2つの円チャートと凡例を中央に置く必要があります。どのようにして凡例の位置を正確に真中に決めることができますか?それはpiechartsをオーバーラップしません。はRで凡例の位置を決定するので、凡例は円グラフと重複しない

par(mfrow = c(1,2)) 
pie(frman, main="Men", col=cols, labels=pielabelsman, cex=0.85) 
pie(frwoman, main="Women", col=cols,labels=pielabelswoman,cex=0.85) 
legend("center", uniq, cex=0.5,fill=cols) 

enter image description here

答えて

0

デフォルトのコマンドによって異なる場所に凡例を置くことができます。

legend("center", uniq, cex=0.5,fill=cols)  
legend("bottomright", uniq, cex=0.5,fill=cols) 
legend("bottom", uniq, cex=0.5,fill=cols) 
legend("bottomleft", uniq, cex=0.5,fill=cols) 
legend("left", uniq, cex=0.5,fill=cols) 
legend("topleft", uniq, cex=0.5,fill=cols) 
legend("top", uniq, cex=0.5,fill=cols) 
legend("topright", uniq, cex=0.5,fill=cols) 
legend("right", uniq, cex=0.5,fill=cols) 
legend("center", uniq, cex=0.5,fill=cols) 

をそうしないと、あなたは、例えば、xとy座標を入力することにより、それを自分で指定することができます。

legend(x = 2, y = 5 , uniq, cex=0.5,fill=cols) 

詳細はこちらhereherehereまたはhereであり、いくつかの例を挙げるに過ぎない。

UPDATE

またして試すことができます:私はそれが右に見えるかどうかを確認することができない、あなたのデータを持っていないが、私はそれが必要だと思うのよう

layout(matrix(c(1,2,3,3), ncol=2, byrow=TRUE), heights=c(4, 1)) 
par(mai=rep(0.5, 4)) 
pie(frman, main="Men", col=cols, labels=pielabelsman, cex=0.85) 
pie(frwoman, main="Women", col=cols,labels=pielabelswoman,cex=0.85) 
par(mai=c(0,0,0,0)) 
plot.new() 
legend("center", uniq, cex=0.5,fill=cols) 

+0

お返事ありがとうございます。私は別のxとyの値で最後の行を試しましたが、私は凡例を観察するのに適切なx、yを見つけることができません。 –

+0

私はpar(mfrow = c(1,2))を使用しているので、x、yは毎回2つのプロットの1つに対応します。 –

+0

@GiorgosVoultsios私は答えを更新しました。 upvoteを忘れず、それがうまくいけば答えを受け入れてください!ありがとう! – adrian1121

関連する問題