Below is an example of how to created titled and stacked maps in Stata. Taken from https://gis.stackexchange.com/questi...ilted-map-in-r
The text and legend placement takes some trial and error.
The text and legend placement takes some trial and error.
Code:
//Download Oregon's census tract shapefile https://www.census.gov/cgi-bin/geo/shapefiles/index.php
clear*
spshape2dta tl_2021_41_tract, saving(oregon) replace
use oregon_shp,clear
replace _X = 2*_X + 1.2*_Y
drop rec
save oregon_shp2, replace
use oregon,clear
set seed 12345
spmap using oregon_shp2, id(_ID) text(45.5 -197 "Census Tracts" ) osize(0.04 ..) name(gr1,replace)
gen x = runiform()
colorpalette viridis, n(10) nograph
local colors `r(p)'
format x %9.2f
spmap x using oregon_shp2, id(_ID) name(gr2,replace) fcolor("`colors'") osize(0.02 ..) ///
clm(c) clb(0 .1 .2 .3 .4 .5 .6 .7 .8 .9 1) legend(on size(*1.2) pos(4) ) ///
text(45.5 -197 "Category X")
gen y = rbeta(4,1)
colorpalette viridis, n(10) nograph
local colors `r(p)'
spmap y using oregon_shp2, id(_ID) name(gr3,replace) fcolor("`colors'") osize(0.02 ..) ///
clm(c) clb(0 .1 .2 .3 .4 .5 .6 .7 .8 .9 1) legend(off) text(45.5 -197 "Category Y")
graph combine gr3 gr2 gr1 , col(1)
