[R] overlay histograms on map at map coordinates
Paul Murrell
p.murrell at auckland.ac.nz
Tue Nov 23 23:26:22 CET 2010
Hi
On 23/11/2010 5:41 p.m., Steve Bellan wrote:
> Hi all,
>
> I'm trying to visualize animal movement data characteristics
> spatiotemporally by overlaying many different histograms on a map. I
> want the histograms to be plotted at coordinates in the map that
> matches a region they describe. If I was just doing this once, I'd
> fiddle in Illustrator after R and avoid the headache. But I'll be
> doing it many many times so it seems worth the elegance& repeatability.
>
> For example, say we have the following data:
>
> covariate<- rep(letters[1:10], each = 100)
> shape.pars<- rep(seq(.5,.7, length.out = 10), each = 100)
> zz<- rgamma(1000, shape = shape.pars, scale = 2)
> map<- data.frame(factor = unique(covariate), xx = rnorm(10), yy =
> rnorm(10))
>
> I'd like to be able to have 10 histograms plotted for each level of
> the covariate at the coordinates specified in the map data.frame.
> Ideally, I'd like to be able to specify whether they were plotted to
> the left, right, top, bottom or center of the coordinates similar to
> in text() and other graphical functions. Looking around the archives,
> all I've come across are the viewport system in library(grid) which
> doesn't seem to be able to handle plot() hist() or other such
> functions. Otherwise, I could create viewports for each histogram
> inside the map's coordinate system.
>
> Any ideas? Thanks!
You can draw 'lattice' or 'ggplot2' plots (e.g., histogram() in
'lattice') within 'grid' viewports.
Paul
> Steve
>
>
> Steve Bellan
> MPH, Epidemiology
> PhD Candidate, Environmental Science, Policy& Management
> Getz Lab
> University of California, Berkeley
>
> ______________________________________________
> 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.
--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
paul at stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/
More information about the R-help
mailing list