How can one change this viridis color platte as shown below to other types of viridis color palette??The code used and the map displayed below is shown for reference:
Changing Viridis to different color palette
181 views Asked by Prabhakar At
2
There are 2 answers
0
On
Since the question asked specifically about the viridis color palette, code would be :
library(mapview)
data(franconia)
mapview(franconia,
zcol = "district",
col.region=viridis::viridis_pal(option = "A"))
Where you can change option="A"
for "B" or "C" (the current palette used is "D").
For using the other gradients from viridis, you can use
library(mapview)
data(franconia)
mapview(franconia,
zcol = "district",
col.region=viridis::mako(n = 3))
where n must be at least as big as the number of discrete variable or bins. For your gradient, I see you have 6 values on your scale, so I'd put n at 6.
The
col.regions
option does that. You can give it a different color palette as an argument:Created on 2022-06-03 by the reprex package (v2.0.1)