开发者

R is plotting labels off the page

开发者 https://www.devze.com 2022-12-29 16:27 出处:网络
i\'m running the following: png(filename=\"figure.png\", width=900, bg=\"white\") barplot(c(1.1, 0.8, 0.7), horiz=TRUE, border=\"blue\", axes=FALSE, col=\"darkblue\")

i'm running the following:

png(filename="figure.png", width=900, bg="white")
barplot(c(1.1, 0.8, 0.7), horiz=TRUE, border="blue", axes=FALSE, col="darkblue")
axis(2, at=1:3, lab=c("eleph开发者_StackOverflowant", "hippo", "snorkel"), las=1, cex.axis=1.3)
dev.off()

and the labels on the left are appearing off the page. I can't seem to figure out how to fix it. Any ideas?

Thanks.


You haven't left enough space in the left margin for labels that long. Try:

png(filename="figure.png", width=900, bg="white")
par(mar=c(5,6,4,1)+.1)
barplot(c(1.1, 0.8, 0.7), horiz=TRUE, border="blue", axes=FALSE, col="darkblue")
axis(2, at=1:3, lab=c("elephant", "hippo", "snorkel"), las=1, cex.axis=1.3)
dev.off()

The 'mar' argument of 'par' sets the width of the margins in the order: 'bottom', 'left', 'top', 'right'. The default is to set 'left' to 4, here I have changed it to 6.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号