Re: [R-sig-Geo] rasterVis: Region colours do not match the legend colours
Hello, However, I would still like to know how to manually set the region colours and extend the range of the legend, if it is possible. You have to use the at argument as you already did. However, you should choose better breaks to display your data correctly. Here you will find an example: http://rastervis.r-forge.r-project.org/FAQ.html#sec-1. I am also dealing with a time component, so while stacking the layers forces all the layer plots to use the same colours at the same values at, say time t=0, the range of data may change after some time has progressed, say at time t=10. Ultimately, the goal would be to make a gif to compare several climate model forecasts over time, like so: http://r-sig-geo.2731867.n2.nabble.com/file/n7584034/testing.gif If the gif is viewable, notice how the legend is changing as the gif animation plays out - I want to, if possible, have the legend fixed and the regions coloured correctly according to the legend. Use layout=c(1, 1). With your data: levelplot(s, layout=c(1, 1)) If you need to create a movie use this code: trellis.device(png, file='Rplot%02d.png') levelplot(s, layout=c(1, 1)) dev.off() ## ffmpeg must be installed in your system movieCMD - 'ffmpeg -i Rplot%02d.png output.mp4' system(movieCMD) Take a look at this thread for more info: https://stat.ethz.ch/pipermail/r-sig-geo/2013-July/018735.html. Best, Oscar. I have read the link about creating an independent legend for each raster layer, but I think I would prefer to have just one legend. Thanks again, Jonathan -- View this message in context: http://r-sig-geo.2731867.n2.nabble.com/rasterVis-Region-colours-do-not-match-the-legend-colours-tp7584032p7584034.html Sent from the R-sig-geo mailing list archive at Nabble.com. ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo -- Oscar Perpiñán Lamigueiro Grupo de Sistemas Fotovoltaicos (IES-UPM) Dpto. Ingeniería Eléctrica (EUITI-UPM) URL: http://procomun.wordpress.com Twitter: @oscarperpinan LinkedIn: http://www.linkedin.com/in/oscarperpinan ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Re: [R-sig-Geo] rasterVis: Region colours do not match the legend colours
Thanks for the reply, Oscar. I tried running the example that you linked, and it did not work. It seems there was something wrong with my R or rasterVis package on my machine. I ran install.packages('rasterVis', dependencies=TRUE), and it said that the package rgl could not be installed with the following error: configure: error: missing required header GL/gl.h. After fixing this, and then installing the 'rgl' package in R, everything seems to work! Thanks again for the help, Jonathan -- View this message in context: http://r-sig-geo.2731867.n2.nabble.com/rasterVis-Region-colours-do-not-match-the-legend-colours-tp7584032p7584043.html Sent from the R-sig-geo mailing list archive at Nabble.com. ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Re: [R-sig-Geo] rasterVis: Region colours do not match the legend colours
Hello, Thanks for the reply, Oscar. Placing the different raster layers into a stack before calling layerplot seems to have fixed the problem. I am able to compare the plots now with the same scale. However, I would still like to know how to manually set the region colours and extend the range of the legend, if it is possible. I am also dealing with a time component, so while stacking the layers forces all the layer plots to use the same colours at the same values at, say time t=0, the range of data may change after some time has progressed, say at time t=10. Ultimately, the goal would be to make a gif to compare several climate model forecasts over time, like so: http://r-sig-geo.2731867.n2.nabble.com/file/n7584034/testing.gif If the gif is viewable, notice how the legend is changing as the gif animation plays out - I want to, if possible, have the legend fixed and the regions coloured correctly according to the legend. I have read the link about creating an independent legend for each raster layer, but I think I would prefer to have just one legend. Thanks again, Jonathan -- View this message in context: http://r-sig-geo.2731867.n2.nabble.com/rasterVis-Region-colours-do-not-match-the-legend-colours-tp7584032p7584034.html Sent from the R-sig-geo mailing list archive at Nabble.com. ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo