R ggplot,删除ggsave/ggplot中的白色边距 [英] R ggplot, remove white margins in ggsave/ggplot
问题描述
如何删除ggsave中的白色边距?
How can I remove the white margins in ggsave?
我的问题与删除R中的ggplot2空白(即边距)相同.但是,答案对我而言并不理想.我想给 ggsave
一个 height
和 weight
而不是一个固定但未知的长宽比的反复试验,并想要我的绘图(即标题的顶部到x标签的底部)以自动扩展到该配置,而没有空白.
My question is exactly the same as Remove white space (i.e., margins) ggplot2 in R. However, the answer there isn't ideal for me. Instead of trial and error for a fixed but unknown aspect ratio, I would like to give ggsave
a height
and weight
and want my plot (ie top of title to bottom of x-label) to automatically expand to that configuration without white margin.
如何删除.png(用r,ggplot绘制)周围奇怪的白色边距?提供了一种方法使边距透明,但它们仍然存在,并且图小于我在保存的文件中设置的 height
和 width
.
How can I remove the strange white margin around my .png (plotted with r, ggplot)? gives a way to make the margin transparent, but they are still there and the plot is smaller than height
and width
I set in the saved file.
推荐答案
theme(plot.margin=grid::unit(c(0,0,0,0), "mm"))
完成工作
这篇关于R ggplot,删除ggsave/ggplot中的白色边距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!