我繪製的圖例超出了繪圖區域。渲染時,圖例的右側部分被截斷。我怎樣才能減少繪圖的寬度,所以它會適合?縮小繪圖寬度,使圖例不會被截斷
# resultValues got 9 cols and 2 rows, colors is a vector with 9 colors
# The maximal y value is 2400
# Setting width to a higher value just streches everthing
pdf("Lineplot.pdf", width = 10, height = 6)
max_y <- max(resultValues)
plot(resultValues$col1, type="o", col=colors[1], ylim=c(0,max_y), axes=FALSE,
ann=FALSE, lwd=1.5)
axis(1, at=1:2, lab=c("2013", "2014"))
axis(2, las=1, at=250*0:max_y)
for (colname in colnames) {
lines(resultValues[[colname]], type="o", lwd=1.5,
col=colors[match(colname, names(resultValues))])
}
box()
par(xpd=TRUE, mar=par()$mar+c(0,0,0,6))
legend(2.05, 2500, legend=names(resultValues), ncol=1, cex=1, fill=colors,
xjust=0, xpd=TRUE)
dev.off()
par(mar=c(5, 4, 4, 2) + 0.1)
你嘗試改變'帕(MAR = C(5,4,4,2)+ 0.1)'?我希望利潤率能夠解決問題。 – Konrad
我做了,但不幸在'plot()'調用之後。像@ bgoldst說的,它必須在它之前完成。 – user3992979