legendgram icon indicating copy to clipboard operation
legendgram copied to clipboard

Add defaults to arguments

Open ljwolf opened this issue 4 years ago • 3 comments

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.

ljwolf avatar Apr 09 '20 16:04 ljwolf

With this functionality, we get something where:

geodataframe.plot('variate')
legendgram(geodataframe.variate)

yields something that should look OK :smile:

ljwolf avatar Apr 09 '20 16:04 ljwolf

~~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)

jGaboardi avatar Nov 02 '23 17:11 jGaboardi

@ljwolf gentle ping to see if there is still interest in getting this merged.

jGaboardi avatar May 16 '24 23:05 jGaboardi