[R-sig-Geo] rasterVis::streamplot with colorkey

Ben Tupper btupper at bigelow.org
Wed Dec 21 17:14:56 CET 2016


Hello,

We have wind data that we would like to draw with rasterVis::streamplot(). We would like to include a colorkey to associate with the region but it seems that deep down rasterVis::streamplot has hardwired `colorkey = FALSE`  I'm not sure how to circumvent this to allow for a color key. So, in brief...  

How do I draw a streamplot with a colorkey?

Below is my example and sessionInfo() output.

Thanks so much,
Ben

### begin example
library(raster)
library(rasterVis)
library(RColorBrewer)

V = volcano/10
V = V - mean(V)
U = V[nrow(V):1,]

V = raster::raster(V)
U = raster::raster(U)
S = raster::stack(U,V)

rasterVis::streamplot(S,
    isField = 'dXY',
    par.settings = rasterVis::streamTheme(
        region = rev(RColorBrewer::brewer.pal(n=4, name= 'Greys')),
        symbol = hexbin::BTC(n=9,beg=20)),
    droplet = list(pc = 1),
    scales = list(draw = TRUE),
    colorkey = TRUE) 

# Error in .local(x, data, ...) : 
#  formal argument "colorkey" matched by multiple actual arguments

### end example


> sessionInfo()
R version 3.3.1 (2016-06-21)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.6 (El Capitan)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rasterVis_0.40      latticeExtra_0.6-28 RColorBrewer_1.1-2  lattice_0.20-33     raster_2.5-8        sp_1.2-3           

loaded via a namespace (and not attached):
[1] zoo_1.7-13        parallel_3.3.1    hexbin_1.27.1     Rcpp_0.12.6       grid_3.3.1        viridisLite_0.1.3





Ben Tupper
Bigelow Laboratory for Ocean Sciences
60 Bigelow Drive, P.O. Box 380
East Boothbay, Maine 04544
http://www.bigelow.org



More information about the R-sig-Geo mailing list