benjann / geoplot

Stata module to draw maps
MIT License
33 stars 3 forks source link

option to pass value labels with `discrete` is specified #9

Closed asjadnaqvi closed 1 year ago

asjadnaqvi commented 1 year ago

The scatter and label options are looking great!

colorpalette tableau, nograph

geoplot ///
    (area nuts3_shp if CNTR_CODE=="FR", lw(0.05) lc(white))  ///
    (line roads_shp if layer!=., colvar(layer) colors(Reds) lw(0.1 0.3 1) discrete ) ///
    (scatter places_shp [aw = population] if popcut==0, msize(0.3)  mc("`r(p1)'%30") mlcolor(%0)) ///
    (scatter places_shp [aw = population] if popcut!=0, msize(1.5)  mc("`r(p2)'%80") mlcolor(white) ) ///
    (label places name _CY _CX if popcut > 0, size(1.5)) ///
    (line nuts1_shp if CNTR_CODE=="FR", lc(black) lw(0.15) ) ///
    , legend(pos(2)) 

Here the roads have value labels 0 "Primary" 1 "Secondary" 2 "Tertiary". It will be great if these can be passed on as legend labels. Or at least the option was not clear:

geoplot_test5

benjann commented 1 year ago

Value labels are passed through if discrete is specified and they are included in the legend unless legend(nolabel) is specified. In my tests this worked without problem. However, I believe that adding value labels to a variable will not update the information on value labels in an alias of that variable (i.e. if value labels are added after the alias has been created, the labels will not show up in the alias). Maybe this is the reason why the labels are not passed through in your case. This is something for StataCorp to fix, not for me :)

benjann commented 1 year ago

I close this. Or is this still an issue? In my tests I did not observe any problem with value labels (except in an alias case as described above).