[R] overlaying a levelplot on a map plot

Felix Andrews felix at nfrac.org
Fri Apr 23 01:13:32 CEST 2010


You don't have to use map() to draw the map.

m <- map(..., plot = FALSE)
xyplot(y ~ x, m, type = "l", aspect = "iso",
  par.settings = list(axis.line = list(col = "transparent")))

or inside a panel function, assuming appropriate scales:
panel.xyplot(m$x, m$y, ...)



On 23 April 2010 04:38, David Winsemius <dwinsemius at comcast.net> wrote:
> On Apr 22, 2010, at 2:24 PM, Kevin Wright wrote:
>
>> Mixing base/lattice graphics can be tricky, but is possible.
>>
>>
>> http://www.bioconductor.org/CRAN/web/packages/gridBase/vignettes/gridBase.pdf
>
> That could be quite useful in the future. Thanks for that.
>
>>
>> Also, did you look at Chapter 13 of the lattice book?
>> http://lmdvr.r-forge.r-project.org/figures/figures.html
>
> I did look at the actual book, and upon doing so yet again, I would say that
> my comments were an accurate, if pithy, summary of the message I take away
> from what very little regarding base graphics appears in that chapter.
>
> --
> David.
>
>>
>> Kevin
>>
>> On Wed, Apr 21, 2010 at 2:08 PM, David Winsemius <dwinsemius at comcast.net>
>> wrote:
>>
>> On Apr 21, 2010, at 2:27 PM, Simon Goodman wrote:
>>
>>>> I've generated a levelplot showing the density distribution of a species
>>>> derived from survey transects, with lon, lat co-ordinates.
>>>>
>>>> I'd like to overlay this on a map of the study region specified by:
>>>>
>>>> map('worldHires', xlim = range(mlon), ylim = range(mlat)), where mlon,
>>>> mlat
>>>> specifies the study region.
>>>>
>>>> > ?map
>>>> No documentation for 'map' in specified packages and libraries:
>>>> you could try '??map'
>>>> > ??map
>>>> > require(maps)
>>>> Loading required package: maps
>>>> > map
>>>
>>> So map uses base graphics.
>>
>>
>>>> I've tried plotting the map first, then using the options: 'add=TRUE,
>>>> axes=FALSE' in the levelplot,
>>>
>>
>>> levelplot is a lattice function. You will have failure with most efforts
>>> to mix base and grid graphics.
>>
>>>> but this doesn't work - a new plot is
>>>> generated for the level plot despite the 'add' option. If I try to add
>>>> the
>>>> map on top of the level plot, they are not to the same scale.
>>>>
>>>> Any suggestions on how to get round this.
>>>>
>>>> Thanks
>>>
>> --
>
> David Winsemius, MD
> West Hartford, CT
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Felix Andrews / 安福立
Postdoctoral Fellow
Integrated Catchment Assessment and Management (iCAM) Centre
Fenner School of Environment and Society [Bldg 48a]
The Australian National University
Canberra ACT 0200 Australia
M: +61 410 400 963
T: + 61 2 6125 4670
E: felix.andrews at anu.edu.au
CRICOS Provider No. 00120C
-- 
http://www.neurofractal.org/felix/



More information about the R-help mailing list