开发者

Losing the grey margin padding in a ggplot

开发者 https://www.devze.com 2023-02-28 14:16 出处:网络
A would like to plot geom_tile() without displaying the surrounding grey frame. 开发者_如何学JAVAExample:

A would like to plot geom_tile() without displaying the surrounding grey frame. 开发者_如何学JAVAExample:

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.

Losing the grey margin padding in a ggplot


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

0

精彩评论

暂无评论...
验证码 换一张
取 消