6

I'm trying to change the colours of a map (shapefile data), created by a code similar to this:

mapView(MyData, zcol="Column_Name")

The "Help" page gives two different ways to change colour by using color= or col.regions=. I would like to add a specific palette (YlGn), but haven't found a way to do so. All it says is:

Error in col2rgb(colors, alpha = alpha) : invalid color name 'YlGn'
Saalva
  • 101
  • 2
  • 7

1 Answers1

15

Here is an example that should clarify the point.

library(mapview)
library(sf)
library(RColorBrewer)

mapview(franconia, zcol = "SHAPE_LEN", col.regions=brewer.pal(9, "YlGn"))

enter image description here

Marco Sandri
  • 23,289
  • 7
  • 54
  • 58