I tried to draw a map using tmap with the color palette in grey scale. However, I can not get the legend to match the actual color in the map.
Here are my codes:
tmap::tm_shape(ut_master_T10) +
tmap::tm_polygons(
col = "t2d.18_64.censusrate.per1k.q5",
palette = c("#FFFFFF", "#DEDEDE", "#BEBEBE", "#5F5F5F", "#000000"),
alpha = 0.7,
lwd = 0.5,
title = "") +
tmap::tm_layout(
frame = FALSE,
legend.outside = TRUE,
legend.hist.width = 5,
legend.text.size = 0.5,
fontfamily = "Verdana") +
tmap::tm_scale_bar(
position = c("LEFT", "BOTTOM"),
breaks = c(0, 10, 20),
text.size = 0.5
) +
tmap::tm_compass(position = c("LEFT", "TOP"))
And here is the picture:
I tried using a different scale (ie viridis), and it is very clear that the color in the legend is lighter than in the actual map.
Thank you!

