I am investigating the effect of a liberalisation of the divorce law on the fertility rates in Danish municipalities (this effect is negative and significant). The data I am using is panel data. To see which municipalities have been affected the most, I have calculated the percentage change in the fertility rate between 2008 and 2018 for each municipality. Now, I want to illustrate this using Stata's command
Code:
spmap
My problem is that the municipalities that are affected the most have the lowest value and thus the lightest shade whereas the municipalities that are affected the least have the highest value and thus the darkest shade. This seems counterintuitive which is why I want to reverse the color scale in the shape map.
Here is my code:
Code:
clear all cd /Users/maigoetzsche/Desktop ssc install shp2dta ssc install spmap use denmark_dat, clear rename NAME_2 municipality replace municipality = "Copenhagen" if municipality =="København" replace municipality = "Ærø" if municipality =="Ærø" replace municipality = "Aarhus" if municipality =="Århus" replace municipality = "Høje-Taastrup" if municipality =="Høje Taastrup" replace municipality = "Vesthimmerlands" if municipality =="Vesthimmerland" save denmark_harm, replace import excel "Datasheets.xlsx", sheet("Data10") firstrow clear drop id save main, replace use denmark_harm, clear merge 1:1 municipality using main spmap divorcechange using denmark_co, plotregion(lcolor(black)) fcolor(OrRd) id(id) osize(vthin vthin vthin vthin) ndsize(vthin) /// legend(position(2)) legtitle("fertilitychange") clnumber(9) legend(size(medium))
Array
Can anyone help?
Thank you in advance.
Best,
Mai
0 Response to Reversing the color scale in shape map using spmap
Post a Comment