colorbar.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:matplotlib-colorbar 作者: ppinard 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号