[R-sig-Geo] plot raster: how to eliminate surrounding white space?

Michael Sumner mdsumner at gmail.com
Tue Aug 27 15:37:02 CEST 2013


I don't get what you mean by "rectangles are closer", but maybe modify
the aspect ratio?
plot(a,axes=FALSE,legend=FALSE, asp = 0.2)

Otherwise, you can control the margins around each plot directly with
a bit of mixing old-school and new:
par(mar = c(0.1, 0.1, 0.1, 0.1), mfrow = c(2,2))
for (i in 1:4) plot(a[[i]], axes=FALSE,legend=FALSE, asp = 0.2)

I don't think you can control the par run by raster's plot function
directly, but if you stop it setting up the whole page like this it
respects each panel it seems.

HTH


On Tue, Aug 27, 2013 at 11:15 PM, Agustin Lobo <alobolistas at gmail.com> wrote:
> I have raster images with many more rows than columns, i.e
> require(raster)
> a <- raster(matrix(200,ncol=256,nrow=3171))
> extent(a) <- c(0,256,0,3177)
>
> and get too much blank space at plotting:
>
> plot(a,axes=FALSE,legend=FALSE)
>
> in particular if I want to display several bands in the same plot:
> a <- stack(a,a*2,a/2,a*3)
> plot(a,axes=FALSE,legend=FALSE)
>
> Is there a way to optimize the plot so that rectangles are closer?
>
> Thanks
>
> Agus
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



-- 
Michael Sumner
Hobart, Australia
e-mail: mdsumner at gmail.com



More information about the R-sig-Geo mailing list