library(tmap)
tm_shape(World)+
tm_polygons(
fill = "#00FF00", # fill color
col = "hotpink", # 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.
ttmp()
## ℹ tmap mode set to "view".
## ℹ switch back to "plot" mode with `tmap::ttm()`
##Data-driven 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
ttmp()
## ℹ tmap mode set to "plot".
## ℹ switch back to "view" mode with `tmap::ttm()`
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")
)
)
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.
tm_shape(World) +
tm_polygons(
fill = "economy",
fill.scale = tm_scale_categorical())
tm_shape(metro) +
tm_bubbles(size = "pop2020") +
tm_basemap("OpenTopoMap")
ttmp()
## ℹ tmap mode set to "view".
## ℹ switch back to "plot" mode with `tmap::ttm()`
tm_shape(metro) +
tm_bubbles(size = "pop2020") +
tm_basemap("CartoDB.DarkMatter")
ttmp()
## ℹ tmap mode set to "plot".
## ℹ switch back to "view" mode with `tmap::ttm()`
tm_shape(metro) +
tm_bubbles(size = "pop2020") +
tm_basemap("Stamen.Watercolor")
## Warning: Stamen is not providing tiles anymore.
## Please use 'Stadia.StamenWatercolor' instead.
## Do not forget to fill the apikey argument (see https://stadiamaps.com/stamen/).
## Warning: Stamen is not providing tiles anymore.
## Please use 'Stadia.StamenWatercolor' instead.
## Do not forget to fill the apikey argument (see https://stadiamaps.com/stamen/).
## [basemaps] Tiles from "Stamen.Watercolor" at zoom level 2 couldn't be loaded
## This message is displayed once per session.
tm_shape(World) +
tm_polygons(
fill = "economy",
fill.chart = tm_chart_bar())
tm_shape(World, crs = "+proj=eqearth") +
tm_polygons(
fill = "HPI") +
tm_layout(bg.color = "skyblue",
earth_boundary = TRUE,
frame = FALSE,
space.color = "white")
tm_shape(World,
bbox = "FULL",
crs = "+proj=ortho +lat_0=30 +lon_0=0") +
tm_polygons() +
tm_xlab("Longitudes") +
tm_ylab("Latitudes")
tm_shape(World,
bbox = "FULL",
crs = "+proj=ortho +lat_0=30 +lon_0=0") +
tm_polygons() +
tm_xlab("Longitudes") +
tm_ylab("Latitudes")+
tm_graticules(n.x = 20, n.y = 10, col = "black", lwd = 2, labels.show = FALSE)
tm_shape(World,
bbox = "FULL",
crs = "+proj=ortho +lat_0=30 +lon_0=0") +
tm_polygons() +
tm_xlab("Longitudes") +
tm_ylab("Latitudes")+
tm_graticules(n.x = 20, n.y = 10, col = "black", lwd = 2, labels.show = FALSE)+
tm_style("natural")