benjann / geoplot

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

Graph Inset On Maps #19

Closed fahad-mirza closed 11 months ago

fahad-mirza commented 1 year ago

Just wondering if there is a possibility to add insets onto maps where we can maybe add things like a histogram, line, bar plots etc. for chosen areas. Think of it as a zoom but instead of zooming a map we end up looking at other bits.

benjann commented 1 year ago

geoplot can do pie charts and bars; see layer types pie and bar in help geoplot. But I guess this is not what you want.

Maybe try command grinset. Type

ssc install grinset, replace

and then:

local url http://fmwww.bc.edu/repec/bocode/i/
geoframe create regions `url'Italy-RegionsData.dta, id(id) coord(xcoord ycoord) ///
    shpfile(Italy-RegionsCoordinates.dta)
geoplot (area regions fortell) (area regions), tight
grinset: twoway (scatter fortell relig3) (lfit fortell relig3) ///
    , title("fortell by relig3") legend(off) graphr(color(gs10))

image

See help grinset for info in how to manipulate size and position.

ben

fahad-mirza commented 1 year ago

Thank you ror this example! Looks nice. But i have a followup question. What if instead of zoom, we want to see histogram of the selected area or line chart etc. or am i over complicating this

benjann commented 1 year ago

Can you show me an example of what you have in mind? (e.g. from a published paper)

fahad-mirza commented 1 year ago

I can try looking for an example from a published paper but I was thinking something like this: https://www.esri.com/arcgis-blog/products/js-api-arcgis/mapping/make-your-histogram-legendary/

Here they display a histogram as a legend but I was thinking like how trends, or distributions are looking like in a certain area / range on the map. I hope I am able to explain my idea properly.

benjann commented 1 year ago

ok, I see. I'm afraid my answer is the same as above. Draw your map using geoplot, then add a histogram or whatever plot you like using grinset. The map and the added plot can use different data sources, that is no problem. Simply load (or change frame to) the data for the added plot before applying grinset. Furthermore, you can apply grinset repeatedly to add multiple plots.

The details will depend on specific application.

fahad-mirza commented 1 year ago

Thanks for the detailed info