[R] How to overlay a global map on a filled contour?

Cable, Sam B Civ USAF AFMC AFRL/RVBXI Sam.Cable at kirtland.af.mil
Fri Aug 10 01:01:37 CEST 2012


Duncan,

I agree that my second code doesn't make sense.  Sorry for the red herring.
I was grasping at straws.

My first code, however, differs from your suggestion only in that I am
asking for a rectangular projection, AFAICT.  As it turns out, I do get
quite different results when asking for the rectangular projection and when
I just accept the default, as in your code.  But neither one actually fits
the map to the region of the filled contour.

I have found a kluge that works, involving re-setting par(usr)  before the
call to map(), but it is really ugly and "empirical".  I am hoping there is
a better way.

Thanks.



-----Original Message-----
From: Duncan Murdoch [mailto:murdoch.duncan at gmail.com] 
Sent: Thursday, August 09, 2012 4:39 PM
To: Cable, Sam B Civ USAF AFMC AFRL/RVBXI
Cc: r-help at r-project.org
Subject: Re: [R] How to overlay a global map on a filled contour?

...

>Your code doesn't quite make sense.  The map function doesn't want to know
the x and y values; it just wants to know the region to plot, which >should
have been set by the data.  So, assuming that filled.contour(lons, lats,
glb.data) produces something sensible, you'd get what you want >with

>filled.contour(lons, lats, glb.data, plot.axes={axis(1); axis(2);
>map(add=TRUE)})

>Duncan Murdoch



More information about the R-help mailing list