benjann / geoplot

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

Legend specific enhancements #3

Closed asjadnaqvi closed 1 year ago

asjadnaqvi commented 1 year ago

The following command generates this map:

geoplot ///
    (area nuts3_shp y_MEDAGEPOP, level(10) colors(CET L20, reverse) )  ///
    (line nuts1_shp, lc(white) lw(0.03) ) ///
    (line nuts0_shp, lc(black) lw(0.1)) ///
    , ///
    legend(pos(2)) 

First, it is great that legends can be binned and continuous and can be placed inside and outside the plot regions! This was a huge issue with spmap that forced them to be inside. Several suggestions:

  1. spmap has a legstyle() option that allows users to customize how the legends are defined. For example, with just showing ranges through a hyphen: 0 - 10 etc. It will be great if these can be ported over.
  2. Option to add and show legends from other layers. For example, I would like to add that I am also showing NUTS1 and NUTS0 boundaries.

geoplot_test1

benjann commented 1 year ago

I now did some work on legend(). It is now possibly to specify label() within each layer to define how legend keys from that layer are generated/labeled, and then in legend() there is a layout() option to put legends from different layers together. Here's an example:

local url http://fmwww.bc.edu/repec/bocode/i/
geoframe create regions `url'Italy-RegionsData.dta, id(id) coord(xcoord ycoord) shpfile(`url'Italy-RegionsCoordinates.dta)
geoframe create capitals `url'Italy-Capitals.dta, coord(xcoord ycoord)
geoplot ///
    (area regions fortell, color(Reds) lc(gs6) finten(60) ///
        label("@lb-@ub")) ///
    (point capitals size, discrete color(Blues) ///
        label(1 "Below 50k")) ///
    (pcarrowi 4139067.2 906564.1 4973321.5 469578.9, color(BlueViolet) ///
        label("Agrigento-Alessandria")) ///
    , legend(bplace(sw) layout(   ///
        - "{bf:Fortell}"     1 |  ///
        - "{bf:City size}"   2    ///
        - "{bf:Other stuff}" 3))  ///
      tight
Graph
benjann commented 1 year ago

I am closing this assuming that the new composite legends solve the issue.