本文整理汇总了Python中matplotlib.contour.ContourSet方法的典型用法代码示例。如果您正苦于以下问题:Python contour.ContourSet方法的具体用法?Python contour.ContourSet怎么用?Python contour.ContourSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.contour
的用法示例。
在下文中一共展示了contour.ContourSet方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_lines
# 需要导入模块: from matplotlib import contour [as 别名]
# 或者: from matplotlib.contour import ContourSet [as 别名]
def add_lines(self, CS, erase=True):
'''
Add the lines from a non-filled
:class:`~matplotlib.contour.ContourSet` to the colorbar.
Set *erase* to False if these lines should be added to
any pre-existing lines.
'''
if not isinstance(CS, contour.ContourSet) or CS.filled:
raise ValueError('add_lines is only for a ContourSet of lines')
tcolors = [c[0] for c in CS.tcolors]
tlinewidths = [t[0] for t in CS.tlinewidths]
# The following was an attempt to get the colorbar lines
# to follow subsequent changes in the contour lines,
# but more work is needed: specifically, a careful
# look at event sequences, and at how
# to make one object track another automatically.
#tcolors = [col.get_colors()[0] for col in CS.collections]
#tlinewidths = [col.get_linewidth()[0] for lw in CS.collections]
#print 'tlinewidths:', tlinewidths
ColorbarBase.add_lines(self, CS.levels, tcolors, tlinewidths,
erase=erase)
示例2: colorbar_factory
# 需要导入模块: from matplotlib import contour [as 别名]
# 或者: from matplotlib.contour import ContourSet [as 别名]
def colorbar_factory(cax, mappable, **kwargs):
"""
Creates a colorbar on the given axes for the given mappable.
Typically, for automatic colorbar placement given only a mappable use
:meth:`~matplotlib.figure.Figure.colorbar`.
"""
# if the given mappable is a contourset with any hatching, use
# ColorbarPatch else use Colorbar
if (isinstance(mappable, contour.ContourSet)
and any([hatch is not None for hatch in mappable.hatches])):
cb = ColorbarPatch(cax, mappable, **kwargs)
else:
cb = Colorbar(cax, mappable, **kwargs)
mappable.callbacksSM.connect('changed', cb.on_mappable_changed)
mappable.colorbar = cb
return cb
示例3: add_lines
# 需要导入模块: from matplotlib import contour [as 别名]
# 或者: from matplotlib.contour import ContourSet [as 别名]
def add_lines(self, CS):
'''
Add the lines from a non-filled
:class:`~matplotlib.contour.ContourSet` to the colorbar.
'''
if not isinstance(CS, contour.ContourSet) or CS.filled:
raise ValueError('add_lines is only for a ContourSet of lines')
tcolors = [c[0] for c in CS.tcolors]
tlinewidths = [t[0] for t in CS.tlinewidths]
# The following was an attempt to get the colorbar lines
# to follow subsequent changes in the contour lines,
# but more work is needed: specifically, a careful
# look at event sequences, and at how
# to make one object track another automatically.
#tcolors = [col.get_colors()[0] for col in CS.collections]
#tlinewidths = [col.get_linewidth()[0] for lw in CS.collections]
#print 'tlinewidths:', tlinewidths
ColorbarBase.add_lines(self, CS.levels, tcolors, tlinewidths)
示例4: __init__
# 需要导入模块: from matplotlib import contour [as 别名]
# 或者: from matplotlib.contour import ContourSet [as 别名]
def __init__(self, ax, mappable, **kw):
mappable.autoscale_None() # Ensure mappable.norm.vmin, vmax
# are set when colorbar is called,
# even if mappable.draw has not yet
# been called. This will not change
# vmin, vmax if they are already set.
self.mappable = mappable
kw['cmap'] = mappable.cmap
kw['norm'] = mappable.norm
kw['alpha'] = mappable.get_alpha()
if isinstance(mappable, contour.ContourSet):
CS = mappable
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
ColorbarBase.__init__(self, ax, **kw)
if not CS.filled:
self.add_lines(CS)
else:
ColorbarBase.__init__(self, ax, **kw)
示例5: add_lines
# 需要导入模块: from matplotlib import contour [as 别名]
# 或者: from matplotlib.contour import ContourSet [as 别名]
def add_lines(self, CS, erase=True):
'''
Add the lines from a non-filled
:class:`~matplotlib.contour.ContourSet` to the colorbar.
Set *erase* to False if these lines should be added to
any pre-existing lines.
'''
if not isinstance(CS, contour.ContourSet) or CS.filled:
raise ValueError('add_lines is only for a ContourSet of lines')
tcolors = [c[0] for c in CS.tcolors]
tlinewidths = [t[0] for t in CS.tlinewidths]
# The following was an attempt to get the colorbar lines
# to follow subsequent changes in the contour lines,
# but more work is needed: specifically, a careful
# look at event sequences, and at how
# to make one object track another automatically.
#tcolors = [col.get_colors()[0] for col in CS.collections]
#tlinewidths = [col.get_linewidth()[0] for lw in CS.collections]
ColorbarBase.add_lines(self, CS.levels, tcolors, tlinewidths,
erase=erase)
示例6: colorbar_factory
# 需要导入模块: from matplotlib import contour [as 别名]
# 或者: from matplotlib.contour import ContourSet [as 别名]
def colorbar_factory(cax, mappable, **kwargs):
"""
Creates a colorbar on the given axes for the given mappable.
Typically, for automatic colorbar placement given only a mappable use
:meth:`~matplotlib.figure.Figure.colorbar`.
"""
# if the given mappable is a contourset with any hatching, use
# ColorbarPatch else use Colorbar
if (isinstance(mappable, contour.ContourSet)
and any(hatch is not None for hatch in mappable.hatches)):
cb = ColorbarPatch(cax, mappable, **kwargs)
else:
cb = Colorbar(cax, mappable, **kwargs)
cid = mappable.callbacksSM.connect('changed', cb.on_mappable_changed)
mappable.colorbar = cb
mappable.colorbar_cid = cid
return cb
示例7: colorbar_factory
# 需要导入模块: from matplotlib import contour [as 别名]
# 或者: from matplotlib.contour import ContourSet [as 别名]
def colorbar_factory(cax, mappable, **kwargs):
"""
Creates a colorbar on the given axes for the given mappable.
Typically, for automatic colorbar placement given only a mappable use
:meth:`~matplotlib.figure.Figure.colorbar`.
"""
# if the given mappable is a contourset with any hatching, use
# ColorbarPatch else use Colorbar
if (isinstance(mappable, contour.ContourSet)
and any([hatch is not None for hatch in mappable.hatches])):
cb = ColorbarPatch(cax, mappable, **kwargs)
else:
cb = Colorbar(cax, mappable, **kwargs)
cid = mappable.callbacksSM.connect('changed', cb.on_mappable_changed)
mappable.colorbar = cb
mappable.colorbar_cid = cid
return cb
示例8: add_lines
# 需要导入模块: from matplotlib import contour [as 别名]
# 或者: from matplotlib.contour import ContourSet [as 别名]
def add_lines(self, CS):
'''
Add the lines from a non-filled
:class:`~matplotlib.contour.ContourSet` to the colorbar.
'''
if not isinstance(CS, contour.ContourSet) or CS.filled:
raise ValueError('add_lines is only for a ContourSet of lines')
tcolors = [c[0] for c in CS.tcolors]
tlinewidths = [t[0] for t in CS.tlinewidths]
# The following was an attempt to get the colorbar lines
# to follow subsequent changes in the contour lines,
# but more work is needed: specifically, a careful
# look at event sequences, and at how
# to make one object track another automatically.
#tcolors = [col.get_colors()[0] for col in CS.collections]
#tlinewidths = [col.get_linewidth()[0] for lw in CS.collections]
ColorbarBase.add_lines(self, CS.levels, tcolors, tlinewidths)
示例9: __init__
# 需要导入模块: from matplotlib import contour [as 别名]
# 或者: from matplotlib.contour import ContourSet [as 别名]
def __init__(self, ax, 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'] = 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
ColorbarBase.__init__(self, ax, **kw)
if not CS.filled:
self.add_lines(CS)
else:
if getattr(cmap, 'colorbar_extend', False) is not False:
kw.setdefault('extend', cmap.colorbar_extend)
if isinstance(mappable, martist.Artist):
kw['alpha'] = mappable.get_alpha()
ColorbarBase.__init__(self, ax, **kw)
示例10: update_normal
# 需要导入模块: from matplotlib import contour [as 别名]
# 或者: from matplotlib.contour import ContourSet [as 别名]
def update_normal(self, mappable):
'''
update solid, lines, etc. Unlike update_bruteforce, it does
not clear the axes. This is meant to be called when the image
or contour plot to which this colorbar belongs is changed.
'''
self.draw_all()
if isinstance(self.mappable, contour.ContourSet):
CS = self.mappable
if not CS.filled:
self.add_lines(CS)