def __init__(self, mappable, **kw):
# Ensure the given mappable's norm has appropriate vmin and vmax set
# even if mappable.draw has not yet been called.
mappable.autoscale_None()
self.mappable = mappable
kw['cmap'] = cmap = mappable.cmap
kw['norm'] = mappable.norm
if isinstance(mappable, contour.ContourSet):
CS = mappable
kw['alpha'] = mappable.get_alpha()
kw['boundaries'] = CS._levels
kw['values'] = CS.cvalues
kw['extend'] = CS.extend
#kw['ticks'] = CS._levels
kw.setdefault('ticks', ticker.FixedLocator(CS.levels, nbins=10))
kw['filled'] = CS.filled
else:
if getattr(cmap, 'colorbar_extend', False) is not False:
kw.setdefault('extend', cmap.colorbar_extend)
if isinstance(mappable, Artist):
kw['alpha'] = mappable.get_alpha()
ticks = kw.pop('ticks', None)
ticklabels = kw.pop('ticklabels', None)
self._base = ColorbarBase2(None, **kw)
if ticks:
self._base.set_ticks(ticks, update_ticks=False)
if ticks and ticklabels:
self._base.set_ticklabels(ticklabels, update_ticks=False)
评论列表
文章目录