You could also try using tmap. Within the tm_raster function you can specify a 
color palette, what value the midpoint of the color palette should be, and even 
set the breaks so that you have different ranges on each side of zero (e.g go 
from -5 to +10 instead of -10 to +10).
________________________________
From: R-sig-Geo <r-sig-geo-boun...@r-project.org> on behalf of rain1290--- via 
R-sig-Geo <r-sig-geo@r-project.org>
Sent: Wednesday, October 12, 2022 10:44 AM
To: r-sig-geo@r-project.org <r-sig-geo@r-project.org>
Subject: [R-sig-Geo] Customizing levelplot coloring scheme in r

I have climate data that I have plotted on a global map using a levelplot map. 
However, I am trying to adjust the default coloring scheme to allow for only 
blue and red shades to appear. Ideally, I am trying to showcase blue for the 
positive values, and red for the negative values, along with a whitish coloring 
near and at 0. The default coloring scheme isn't bad, but I think a 
blue-red-white coloring would allow the plot to appear more visually pleasing. 
Here is the code that I have now to create my current levelplot:

#packages installed


library(raster)
library(ncdf4)
library(maps)
library(maptools)
library(rasterVis)
library(ggplot2)
library(rgdal)
library(sp)
library(gridExtra)
library(grid)
library(RColorBrewer)

#Using levelplot

FPlot10 <- levelplot(FDifference5,margin=F,at=c(seq(-50,150,10)),pretty=TRUE,
par.settings=mapTheme, main="Higher end")
FM10 <- FPlot10 + latticeExtra::layer(sp.lines(world.outlines.sp))

This yields a range of nice default colors, but I'd like to adopt something 
with only shades of red and blue (with white at and around 0). I can do it 
easily in ggplot, but levelplot appears completely different in using color 
commands (if they exist). Is that even possible in levelplot?
Thank you!
        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-geo&amp;data=05%7C01%7Cailich%40usf.edu%7C4cbfb9fce68b4842fec308daac604d98%7C741bf7dee2e546df8d6782607df9deaa%7C0%7C0%7C638012598934423717%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=KMXznsbBZW4onMZbbXkfGscLqIGtITpsO8eoi7c9exo%3D&amp;reserved=0
[EXTERNAL EMAIL] DO NOT CLICK links or attachments unless you recognize the 
sender and know the content is safe.

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to