丢失 ggplot 中的灰色边距填充
A 想要绘制 geom_tile() 而不显示周围的灰色框架。示例:
library(ggplot2)
p <- ggplot(melt(volcano), aes(x = X1, y = X2, z = value,fill = value)) + geom_tile()
print(p)
生成下图,如果主题背景没有正确框住热图,该图看起来会更好。我想象中的填充与基础图形中的填充相同,为 4%。大多数时候拥有它是件好事,但并非总是如此。
我认为这个问题的相同解决方案也可以应用于其他几何体。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需执行 print(p1 + scale_x_continuous(expand = c(0, 0)) + scale_y_continuous(expand = c(0, 0))) 即可消除周围的灰色空间
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