creare-com / podpac

Pipeline for Observational Data Processing Analysis and Collaboration
https://podpac.org
Apache License 2.0
45 stars 6 forks source link

Enable non-contiguous enumerations #506

Open joffreypeters opened 1 year ago

joffreypeters commented 1 year ago

Description The current enumeration legend styling assumes a contiguous enumeration from min to max of the enumeration values. There are datasets with non-contiguous enumerations which end up with "dead space" values in their legends from this choice.

Describe the solution you'd like

Change the enumeration legend in core/style to generate a list of enumeration values rather than creating a range from min to max.

Additional context Here's a non-contiguous USCS soils legend, showing a bunch of "black" values in the non-contiguous region:

image

mpu-creare commented 1 year ago

Looks like matplotlib's ListedColormap does not support this directly.

You might be able to to this with a custom Norm, something like this: https://matplotlib.org/stable/api/_as_gen/matplotlib.colors.BoundaryNorm.html#matplotlib.colors.BoundaryNorm -- https://stackoverflow.com/questions/9707676/defining-a-discrete-colormap-for-imshow-in-matplotlib