library(tmap)
##Constant visual values
tm_shape(World)+
tm_polygons(
fill = "#0000ff", # 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.
##color change
tm_shape(World)+
tm_polygons(
fill = "#0000ff", # fill color
col = "black", # line color
lwd = 0.5, # line width
lty = "dashed") # line type
##using symbol
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")
##Scales: numeric data (intervals)
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
))
##Scales: numeric data (continuous)
tm_shape(World)+
tm_polygons(
fill = "HPI",
fill.scale = tm_scale_continuous(
limits = c(10, 60),
values = "scico.hawaii"))
## [plot mode] fit legend/component: Some legend items or map compoments do not
## fit well, and are therefore rescaled.
## ℹ Set the tmap option `component.autoscale = FALSE` to disable rescaling.
ttmp()
## ℹ tmap mode set to "view".
## ℹ switch back to "plot" mode with `tmap::ttm()`