R 正在绘制页面之外的标签

发布于 2024-09-01 00:38:49 字数 444 浏览 5 评论 0原文

我正在运行以下命令:

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("elephant", "hippo", "snorkel"), las=1, cex.axis=1.3)
dev.off()

左侧的标签出现在页面之外。我似乎不知道如何解决它。有什么想法吗?

输入图片此处描述

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("elephant", "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?

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦醒时光 2024-09-08 00:38:49

您没有在左边距中为那么长的标签留出足够的空间。尝试:

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()

“par”的“mar”参数按以下顺序设置边距宽度:“底部”、“左侧”、“顶部”、“右侧”。默认设置 'left' 为 4,这里我将其更改为 6。

在此处输入图像描述

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.

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文