[R-sig-Geo] rasterVis, multiple plots and scalebar labels
Tim Appelhans
tim.appelhans at gmail.com
Sat Sep 24 09:59:27 CEST 2016
Is this producing what you want?
rasterVis::levelplot(xx, colorkey = list(at = at, labels = labels))
colorkey takes a list of arguments, including at and labels. This way it
can be differentiated from the at passed to levelplot itself.
Tim
On 24.09.2016 02:59, Ben Tupper wrote:
> Hi Melanie,
>
> Thanks for this. I tried that approach by adding layers with the latticeExtra package - no joy yet. My lattice skills are a bit wobbly - but I have The Good Books in hand so I'll keep noodling around and may prevail yet.
>
> https://www.r-project.org/doc/bib/R-books_bib.html#R:Sarkar:2008
> https://www.r-project.org/doc/bib/R-books_bib.html#R:Bivand+Pebesma+Gomez-Rubio:2008
> http://oscarperpinan.github.io/spacetime-vis/
>
> Cheers,
> Ben
>
>> On Sep 23, 2016, at 12:55 PM, Bacou, Melanie <mel at mbacou.com> wrote:
>>
>> Here is a stump that might also work with levelplot():
>>
>> # Plot raster with no scalebar first
>> raster::plot(r, col=vector_of_colors, legend=FALSE, axes=FALSE)
>>
>> # Add a custom scalebar
>> raster::plot(r, legend.only=TRUE,
>> col=vector_of_colors,
>> axis.args=list(at=1:length(vector_of_labels), labels=vector_of_labels)
>>
>>
>> On 9/23/2016 12:11 PM, Ben Tupper wrote:
>>> Hi,
>>>
>>> I would like to specify the labels drawn on the scalebar for a multi-raster plot. I have seen this exchange (and try to replicate for multiple rasters below)
>>>
>>> https://stat.ethz.ch/pipermail/r-help/2011-August/286705.html
>>>
>>> I can't make that work with rasterVis::levelplot()
>>>
>>> # start preparatory
>>> library(raster)
>>> library(rasterVis)
>>>
>>> x <- raster::raster(volcano,
>>> crs = '+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0',
>>> xmn = -45, xmx = -40, ymn = 39, ymx = 47)
>>> xx <- addLayer(x,x,x)
>>>
>>> at <- seq(90, 200, length = 10)
>>> labels <- rep(" ", length(at))
>>> labels[1] <- "low"
>>> labels[length(labels)] <- "high"
>>> # end preparatory
>>>
>>> # try as in help exchange above - ticks are labeled with numerics
>>> rasterVis::levelplot(xx,
>>> colorkey = list(at = at),
>>> labels = list(labels = labels, at = at) )
>>>
>>> # try as described in ?rasterVis::levelplot section for labels
>>> # ticks still labeled with numerics
>>> rasterVis::levelplot(xx,
>>> at = at,
>>> labels = labels )
>>>
>>> I'm stumped! How do I control the tick labels on a scalebar?
>>>
>>> Thanks!
>>> Ben
>>>
>>>
>>>> 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
>>> [5] raster_2.5-8 sp_1.2-3
>>>
>>> loaded via a namespace (and not attached):
>>> [1] zoo_1.7-13 rgdal_1.1-10 parallel_3.3.1 hexbin_1.27.1
>>> [5] 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
>>>
>>> _______________________________________________
>>> R-sig-Geo mailing list
>>> R-sig-Geo at r-project.org
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> Ben Tupper
> Bigelow Laboratory for Ocean Sciences
> 60 Bigelow Drive, P.O. Box 380
> East Boothbay, Maine 04544
> http://www.bigelow.org
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
--
#####################################
Tim Appelhans
Department of Geography
Environmental Informatics
Philipps Universität Marburg
Deutschhausstraße 12
Raum 00A08
35032 Marburg (Paketpost: 35037 Marburg)
Germany
Tel +49 (0) 6421 28-25957
http://environmentalinformatics-marburg.de/
More information about the R-sig-Geo
mailing list