Error when discrete colorbar only has two values
Issue #45
resolved
An ZeroDivisionError will occur when a discrete value colorbar only have two values.
Comments (3)
-
reporter -
reporter It even has trouble dealing with 3 boundaries even though it's only an divide by zero warning.
-
reporter - changed status to resolved
Fix issue
#45matplotlib does not like discrete colorbar with only two values, by implement internal logic to stop it from being possible.→ <<cset 83ff0527b468>>
- Log in to comment
After looking at matplotlib's code a bit (v1.4.3), I think this is a matplotlib bug: In the routine that calculates the position of color patches, it never take into account of the case with two boundaries (which make logical sense in drawing, but simply odd and rare). It fails when tries to deal with calculating 'extend' option, even when extend is not used.
One potential solution is to fake this discrete mode by continuous mode and make two ends same color.
One other option is to enforce that discrete cannot have less than 3 values (but continous one can).