ggplot2 生成的切片图

发布于 2024-09-14 15:42:13 字数 133 浏览 1 评论 0原文

我想知道是否可以将图形分别切片为使用 ggsave 生成​​的 .png 文件。如果我不想使用默认的图例或标题并将其设置为 FALSE,则会留下大量空白。那么有没有一种 R 方法可以将文件剪切到图形本身上方和下方几个像素呢?

提前谢谢!

I wonder if it's possible to slice a graph respectively a .png file generated with ggsave. If I do not want to use the default legend ort title and set it to FALSE it leaves me with a lot of white space. So is there an R way to just cut the file several pixels above and below the graph itself?

Thx in advance!

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

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

发布评论

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

评论(1

少年亿悲伤 2024-09-21 15:42:13

您可以更改 plot.margin,例如

p + opts(plot.margin=unit(c(-1, 0, -1, 0), "lines"))

,从版本 0.9.2 开始,opts 已变为 替换为主题

p + theme(plot.margin = unit(c(-1, 0, -1, -), "lines"))

You could change the plot.margin, e.g.

p + opts(plot.margin=unit(c(-1, 0, -1, 0), "lines"))

Since version 0.9.2 opts has been replaced by theme:

p + theme(plot.margin = unit(c(-1, 0, -1, -), "lines"))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文