Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Losing the grey margin padding in a ggplot

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. heatmap

like image 370
gappy Avatar asked Apr 24 '11 01:04

gappy


1 Answers

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

like image 78
Ramnath Avatar answered Sep 28 '22 09:09

Ramnath