默认命令可以将图例放置在不同的地方:
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,仅举一些例子。
更新
你也可以试试:
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)
由于我没有您的数据,我无法检查它是否正确,但我认为应该。