benjann / geoplot

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

Legend labels/values enclosed by (,] and [,] #20

Closed ericmelse closed 9 months ago

ericmelse commented 10 months ago

CBS_MobilityProv_20230705.zip

Dear Ben, I continue my exploration of geoplot using the same shpfile for the map of The Netherlands. Now I use data to color code the regions, using the variable VerplaasTot which is the average number of persons that move by any means of transportation (as reported here by Statistics Netherlands). I attached the necessary files, should you want to replicate, and my code is:

clear all
frames reset
geoframe create regions NLD_prov_Verplaatsingen, id(_ID) coord(_CX _CY) shpfile(NLD_prov_shp.dta)
geoframe generate plevel

local textclr ""58 144 254"*1.4"
geoplot ///
    (area regions moveTot, lw(*.3) lc(gs7) ///         
    cuts(2.5(.05)2.9) /// => 17 bins
        color(gs14 "168 144 8", ipolate(10) intensity(.8))) ///
    , xsize(4.2) ysize(5) ///
    legend(pos(5) layout(1 - "Mobility")) /// , m(t+1 b-1) ztitle(c(blue)) ///
    compass(t(1) pos(2) si(2.3) xm(.2) ym(.2) c(gs9) lab(si(*.5) c(`textclr') gap(50))) /// 
    sbar(units(km) ym(2) c(gs8) lab(si(*.55) c(gs5)))

Which results in: CBS_Legend_Label_Braces_XL The map itself and the color coding is fine. But, the legend labels/values are enclosed, mostly, by (,] and by [,] for the first color code. I assume that the use of the round and straight bracket is controlled internally by geoplot. I suppose it has to be either an enclosing round or straight bracket at every label. Maybe some correction is needed. Having said that, I welcome an option to select either round or straight brackets to enclose label values of the legend.

benjann commented 10 months ago

This is mathematical notation. [] is a closed interval (closed on both sides); (] is an interval that is open on the left and closed on the right. Use option label() to define how the intervals will be labeled. The default is label(1 = "[@lb,@ub]" * = "(@lb,@ub]") because this how geoplot defines the intervals. Type, for example, label(* = "[@lb,@ub]") or label("[@lb,@ub]") to use brackets for all intervals. See the information on label() for details. You can also type label("@lab") which is a synonym for label("@lb - @ub"); some people prefer such labels over the mathematical notation.

ericmelse commented 10 months ago

Thank you for explaining it all. I got it working now just fine!