legendgram
legendgram copied to clipboard
Add defaults to arguments
This adds a few enhancements relating to default arguments & alternative position/size options for loc
. It also moves the examples folder to notebooks
, to keep in line with other PySAL projects.
defaults
- add a default for the
breaks
that is 10 evenly-spaced percentiles - add a default for the
pal
that is'viridis'
- add a default for the figure/axis that defaults to the current axis.
position/size options
interpret a loc = (x,y,w,h)
tuple as the first two coordinates being the anchor (left bottom corner of the new axis) and the second two being the width & height of the new axis, relative to the existing axis. So, (0,0,.5,.25)
would nominally start in the lefthand corner, stretch to the middle of the plot, and grow to the bottom half.
We could make that better for UX by providing a separate width ratio thing, but I think since position & width/height affect each other depending on the later matplotlib spacing calls (e.g. f.tight_layout()
can really squeeze/realign the subaxis), I liked keeping this tuple as a two or four.
With this functionality, we get something where:
geodataframe.plot('variate')
legendgram(geodataframe.variate)
yields something that should look OK :smile:
~~Done. No test though... 😶🌫️~~
EDIT
@ljwolf :
- I updated the testing suite and can confirm that all pass locally (Python 3.12)
- Found bug in the previous gist and corrected
- Now testing for all scenarios in
util._get_cmap()
and confirm plotting is as expected locally - Coverage at 94%
- Converted tests to
pytest
- Removed
pysal.contrib.viz.mapping
(xref #7)
@ljwolf gentle ping to see if there is still interest in getting this merged.