> (1) First, I would like to plot a categorical variable with 2 values,
> so I'm using the -clmethod(unique)- option. So there is a total number
> of 3 different colors in my map "treated", controls" and "no values".
> But I haven't been able to figure out a way to get a legend that will
> display the labels ("treated","control","no values") instead of the
> values (1,0,.)?
This result can be easily achieved by attaching the desired labels to the values of the variable of interest. Here's an example based on the datasets distributed with -spmap-:
. use "Italy-RegionsData.dta", clear
. generate y = fortell<17
. replace y = . if inlist(id,1,10)
. label define y 0 "control" 1 "treated", modify
. label values y y
. spmap y using "Italy-RegionsCoordinates.dta", id(id) clmethod(unique) ndlabel("no values")
> (2) A bit more complicated: My base map delineates the areas of
> different districts, which in turn belong to a number of different
> states. Now I would like to plot the districts and color them
> according to the values of different non-geograpphic variables, but I
> would also like to clearly show the borders of the different states.
> My polygons describe only the districts within the states, I only have
> a database variable that tells me for each district which state it's
> in. So I'm wondering:
> (a) Is there any way to add a border around the states with my current
> data. Or is there any way to construct an additional data layer with
> the state polygons based on the district polygons within them?
> (b) If not, can I at least use different color schemes within each state?
> (c) Or is my goal only achievable if I already have the polygons as a
> shape file also for the states?
The easiest way to achieve this goal is following approach (c). For example:
. spmap fortell using "Italy-RegionsCoordinates.dta", id(id) ///
ocolor(white ..) osize(*1.5 ..) fcolor(Reds) ///
polygon(data("Italy-OutlineCoordinates.dta") osize(*1.5))
After some data manipulation, in principle JZ might also follow approach (b), but I'm not sure that would be a good idea (I guess the resulting map would be quite difficult to read).
Best,
Maurizio
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/