‘one more break’ error in sf plot. How to manipulate color palette for a continuous column in pal argument of sf plot function

92 views Asked by At

I wonder why I the code below only works when I use 11 in the number of colors for hcl.colors function? Using other values caused an error must have one more break than colour. If I’d like to represent the data in 4 class, for instance, what should I do? Would appreciate if someone could help me understand the reason.

dat1 <- rnaturalearth::ne_countries(returnclass = "sf", scale = 110)
plot(dat1["gdp_md_est"],
     key.pos = 4, 
     axes = FALSE,
     pal = hcl.colors(11, "Dark Mint", rev = TRUE),
     key.width = lcm(1.3), key.length = 0.75
)

using 11 colors produced the below map: r

0

There are 0 answers