Because that's the way rasters work - they have to fill up the total
space you give them. If you reduce the number of pixels, each pixel
gets bigger.
> As a workaround
> I tried using NAs in the grid.
>
> df = expand.grid(x=-10:10, y=-10:10)
> df$z = rnorm(nrow(df))
> df$z[abs(df$x) + abs(df$y) <= 15] = NA
> plot = (ggplot(df, aes(x, y))
> + geom_raster(aes(fill=z))
> + coord_equal())
>
> print(plot)
>
> NAs are rendered with a grey color, but where is that color defined? I'd
> like to use white or alpha=0.
Try
plot + scale_fill_gradient(na.value = NA)
Hadley
--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/
Because that's the way rasters work - they have to fill up the total
space you give them. If you reduce the number of pixels, each pixel
gets bigger.
plot + scale_fill_gradient(na.value = NA)