Asjad Naqvi released a new version of the bimap package, let me provide a small update of the following blog. The main difference will be that I will use the geoplot package to create a frame.
First, let us look at the result of this updated code:
Now let us look at the code. First, I use the dataset containing the Natural Earth Data with _ID, the Spatial-unit ID, _CX and _CY, x-coordinate and y-coordinate of area centroid. I merge these data with my database containing economic data for the Chinese provinces. Then, I keep specific years and I make an average for inflation and growth in Chinese province between 2010 and 2015, as suggested by my co-author Linda Glawe. The next step is to save this file to declare a frame named ‘regions’ with the geoplot package. Do not forget to change shpfile() by shp()
in my previous code. Declare the frame with frame change regions
Finally, you can use the same code with the frame option, bimap inflation growth, frame(regions)
and use the same options as before.
// New bimap version
/// New geoplot ///
use ne_10m_admin_1_states_provinces.dta,clear
merge 1:m _ID using "data/dataset_yearly_maps.dta", nogenerate
keep if year>= 2010
keep if year<= 2015
generate g2_gdppc_const05_new100=g2_gdppc_const05_new*100
sort unit_id year
by unit_id: egen growth = mean(g2_gdppc_const05_new100)
by unit_id: egen inflation = mean(cpi_new)
*keep if iso_a2 == "CN" | iso_a2 == "TW"
keep if year==2015
save ne_10m_admin_1_states_provinces_bis.dta, replace
/// New geoplot ///
geoframe create regions ///
ne_10m_admin_1_states_provinces_bis.dta, id(_ID) ///
coord(_CX _CY) ///
shp(ne_10m_admin_1_states_provinces_shp.dta) ///
replace
/// Replace shpfile() by shp()
geoframe describe regions
frame change regions
*preserve
bimap inflation growth, frame(regions) cut(pctile) ///
palette(bluered) ///
title("{fontface Arial Bold:Bivariate Map of Regional Inflation and Growth}") ///
note("Data from the National Bureau of Statistics of China. Averaged data between 2010 and 2015.") ///
textx("Growth") texty("Inflation") texts(3.5) textlabs(3) values count ///
ocolor(black) osize(0.05) ///
polygon(data("ne_10m_admin_0_countries_shp") ///
select(keep if _ID==189) ocolor(black) osize(0.05)) ///
vallabs(1.8)
*restore
graph rename Graph bimap2010_15, replace
graph export bimap2010_15.pdf, as(pdf) replace
More details on how to draw maps for Chinese regions: