Skip to content

Cannot initialize ColorbarBase without a norm. #3805

Closed
@chebee7i

Description

@chebee7i

In 1.3.1, the following code used to work:

import matplotlib
import matplotlib.pyplot as plt
ax = plt.gca()
matplotlib.colorbar.ColorbarBase(ax, plt.cm.bone)

But now, I get an error:

/home/me/.virtualenvs/py27/matplotlib/lib/matplotlib/colorbar.py in _process_values(self, b)
    656             self.norm.vmin, self.norm.vmax = mtrans.nonsingular(self.norm.vmin,
    657                                                                 self.norm.vmax,
--> 658                                                                 expander=0.1)
    659             if not self.norm.scaled():
    660                 self.norm.vmin = 0

/home/me/.virtualenvs/py27/matplotlib/lib/matplotlib/transforms.py in nonsingular(vmin, vmax, expander, tiny, increasing)
   2640     returns -*expander*, *expander*.
   2641     '''
-> 2642     if (not np.isfinite(vmin)) or (not np.isfinite(vmax)):
   2643         return -expander, expander
   2644     swapped = False

TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

The issue is that vmin and vmax are both None.

Using git bisect, I was able to track it down to e9f9e6c which relates to #2642. I'm not familiar enough with the matplotlib internals to know the overall intent here. Is this a regression or the new, preferred behavior? If so, how should I be modifying the code? @efiring, I'm guessing you'll figure this one out with a quick glance.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions