[R] ggplo2: fixed extent greater than data?

thegeologician kmr at thegeologician.net
Fri Nov 23 19:20:26 CET 2007


Hi everyone!

I'm digging into ggplot for some while now, I must say it's great! But - as
some others have posted before, and hadley knows very well himself - the
documentation is lacking some bits...

So I have to pose that question directly:

I'd like to produce a series of maps with different data on, but exactly the
same extent in each plot. Is there a way of switching the automatic extent
(to the data of the last layer added) OFF? I'm trying something like:

drawOverviewMap<-function(){

p2<-ggplot(xlimits=c(2,20),ylimits=c(43,50))+coord_map(project="azequalarea")
	p2<-p2+geom_path(data=wa,mapping=aes(x=x,y=y))
	p2<-p2+geom_point(data=spts,mapping=aes(x=Lon,y=Lat))
	return(p2)
}

If I plot this in cartesian coordinates, it will zoom to the extent of the
country boundaries "wa", plus some extra space around it (since this is the
dataset with the widest range). This extent can be fixed with the
"limits=..." parameter. If I plot it in a map projection, as shown above, it
zooms to the extent of the sample localities "spts" (plus extra space). ;-(

Additional question: is there a way of eliminating the extra spacing in a
map projection? The "expand=c(0,0)" parameter seems not to work...

Thanks very much!
-- 
View this message in context: http://www.nabble.com/ggplo2%3A-fixed-extent-greater-than-data--tf4863198.html#a13916848
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list