Error when discrete colorbar only has two values

Issue #45 resolved
Angus Yeh repo owner created an issue

An ZeroDivisionError will occur when a discrete value colorbar only have two values.

Comments (3)

  1. Angus Yeh reporter

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

  2. Angus Yeh reporter

    It even has trouble dealing with 3 boundaries even though it's only an divide by zero warning.

  3. Log in to comment