您可以通過默認命令放置在不同的地方傳說:
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)
你可以找到更多的信息here,here,here或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)
由於我沒有數據,我不能檢查它是否看起來正確與否,但我認爲它應該。
感謝您的回覆。我已經嘗試過使用不同的x和y值的最後一行,但我無法找到合適的x,y來觀察圖例。 –
事情是我使用par(mfrow = c(1,2)),所以x,y對應於每次兩個圖中的一個 –
@GiorgosVoultsios我更新了答案。如果有效,不要忘記註冊並接受答案!謝謝! – adrian1121