切割由ggplot2生成的图 [英] Slicing plots generated by ggplot2

查看:94
本文介绍了切割由ggplot2生成的图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以分别对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提前!

推荐答案

您可以更改 plot.margin ,例如

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

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

.2 opts 已被取代 by theme

Since version 0.9.2 opts has been replaced by theme:

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

这篇关于切割由ggplot2生成的图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆