丢失ggplot中的灰色边缘填充 [英] Losing the grey margin padding in a ggplot

查看:138
本文介绍了丢失ggplot中的灰色边缘填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想要绘制geom_tile()而不显示周围的灰色框。例子:

pre $ library $ ggplot2
p < - ggplot(melt(volcano),aes(x = X1, y = X2,z = value,fill = value))+ geom_tile()
print(p)

生成下图,如果没有主题背景框住热图,本文看起来会更好。成像填充与基础图形相同,为4%。大部分时间都可以使用它,但并非总是如此。



我假设这个问题的解决方案也可以应用于其他几何体。

解决方案

打印(p1 + scale_x_continuous(expand = c(0,0))+ scale_y_continuous(expand = c(0,0)))和这将摆脱
周围的灰色空间

A would like to plot geom_tile() without displaying the surrounding grey frame. Example:

library(ggplot2)
p <- ggplot(melt(volcano), aes(x = X1, y = X2, z = value,fill = value)) + geom_tile() 
print(p)

Produces the figure below, which would look better had not the theme background framed the heatmap proper. I imaging the padding is the same 4% as in base graphics. It's good to have it most of the time, but not always.

I assume the same solution to this problem could be applied to other geoms as well.

解决方案

just do print(p1 + scale_x_continuous(expand = c(0, 0)) + scale_y_continuous(expand = c(0, 0))) and that will get rid of the gray space around

这篇关于丢失ggplot中的灰色边缘填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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