library(tmap)
data(World)
tm_shape(World) +
tm_polygons(
fill = "#ffce00", # fill color
col = "black", # line color
lwd = 0.5, # line width
lty = "dashed" # line type
)
## [tip] Consider a suitable map projection, e.g. by adding `+ tm_crs("auto")`.
## This message is displayed once per session.

tm_shape(World)+
tm_polygons(fill = "grey90") + # constant fill color
tm_symbols(size = "pop_est", # data variable, mapped to symbol size
fill = "well_being", # data variable, mapped to symbol fill color
shape = "income_grp") # data variable, mapped to symbol shape

tm_shape(World)+
tm_polygons(fill = "HPI")

tm_shape(World)+ tm_polygons(
fill = "HPI",
fill.scale = tm_scale_intervals(
style = "fisher", # a method to specify the classes
n = 7, # number of classes
midpoint = 38, # data value mapped to the middle palette color
values = "pu_gn_div" # color palette;
# run cols4all::c4a_gui() to explore color palettes
))

tm_shape(World)+ tm_polygons(
fill = "HPI",
fill.scale = tm_scale_intervals(
n = 6, # for n classes
style = "fixed",
breaks = c(0,10,20,30,40,50,60), # you need n+1 number of breaks
values = "pu_gn_div"
))

tm_shape(World) +
tm_polygons(
fill = "HPI",
fill.scale = tm_scale_intervals(
breaks = c(0, 10, 20, 30, 40, 50, 60),
values = "pu_gn_div",
labels = c("0–10", "10–20", "20–30", "30–40", "40–50", "50–60")
)
)
