本文整理汇总了Python中matplotlib.collections.PatchCollection.get_cmap方法的典型用法代码示例。如果您正苦于以下问题:Python PatchCollection.get_cmap方法的具体用法?Python PatchCollection.get_cmap怎么用?Python PatchCollection.get_cmap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.collections.PatchCollection
的用法示例。
在下文中一共展示了PatchCollection.get_cmap方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: str
# 需要导入模块: from matplotlib.collections import PatchCollection [as 别名]
# 或者: from matplotlib.collections.PatchCollection import get_cmap [as 别名]
#.........这里部分代码省略.........
- "log": log scale (cannot have negative values)
- "symlog": symmetric log scale (negative values are ok)
- any matplotlib.colors.Normalize instance, e. g. PowerNorm(gamma=-2)
'''
return self.pixels.norm
@norm.setter
def norm(self, norm):
if norm == 'lin':
self.pixels.norm = Normalize()
elif norm == 'log':
self.pixels.norm = LogNorm()
self.pixels.autoscale() # this is to handle matplotlib bug #5424
elif norm == 'symlog':
self.pixels.norm = SymLogNorm(linthresh=1.0)
self.pixels.autoscale()
elif isinstance(norm, Normalize):
self.pixels.norm = norm
else:
raise ValueError("Unsupported norm: '{}', options are 'lin',"
"'log','symlog', or a matplotlib Normalize object"
.format(norm))
self.update(force=True)
self.pixels.autoscale()
@property
def cmap(self):
"""
Color map to use. Either a name or `matplotlib.colors.ColorMap`
instance, e.g. from `matplotlib.pyplot.cm`
"""
return self.pixels.get_cmap()
@cmap.setter
def cmap(self, cmap):
self.pixels.set_cmap(cmap)
self._update()
@property
def image(self):
"""The image displayed on the camera (1D array of pixel values)"""
return self.pixels.get_array()
@image.setter
def image(self, image):
"""
Change the image displayed on the Camera.
Parameters
----------
image: array_like
array of values corresponding to the pixels in the CameraGeometry.
"""
image = np.asanyarray(image)
if image.shape != self.geom.pix_x.shape:
raise ValueError(
"Image has a different shape {} than the "
"given CameraGeometry {}"
.format(image.shape, self.geom.pix_x.shape)
)
self.pixels.set_array(image[self.geom.mask])
self.pixels.changed()
if self.autoscale:
示例2: bool
# 需要导入模块: from matplotlib.collections import PatchCollection [as 别名]
# 或者: from matplotlib.collections.PatchCollection import get_cmap [as 别名]
#.........这里部分代码省略.........
# enabled on-the-fly later as well:
if allow_pick:
self.enable_pixel_picker()
if image is not None:
self.image = image
else:
self.image = np.zeros_like(self.geom.pix_id, dtype=np.float)
def enable_pixel_picker(self):
""" enable ability to click on pixels """
self.pixels.set_picker(True) # enable click
self.pixels.set_pickradius(sqrt(u.Quantity(self.geom.pix_area[0])
.value) / np.pi)
self.pixels.set_snap(True) # snap cursor to pixel center
self.axes.figure.canvas.mpl_connect('pick_event', self._on_pick)
def set_limits_minmax(self, zmin, zmax):
""" set the color scale limits from min to max """
self.pixels.set_clim(zmin, zmax)
self.update()
def set_limits_percent(self, percent=95):
""" auto-scale the color range to percent of maximum """
zmin = self.pixels.get_array().min()
zmax = self.pixels.get_array().max()
dz = zmax - zmin
frac = percent / 100.0
self.set_limits_minmax(zmin, zmax - (1.0 - frac) * dz)
@property
def cmap(self):
return self.pixels.get_cmap()
@cmap.setter
def cmap(self, cmap):
""" Change the color map
Parameters
----------
self: type
description
cmap: `matplotlib.colors.ColorMap`
a color map, e.g. from `matplotlib.pyplot.cm.*`
"""
self.pixels.set_cmap(cmap)
self.update()
@property
def image(self):
return self.pixels.get_array()
@image.setter
def image(self, image):
"""
Change the image displayed on the Camera.
Parameters
----------
image: array_like
array of values corresponding to the pixels in the CameraGeometry.
"""
image = np.asanyarray(image)
if image.shape != self.geom.pix_x.shape:
raise ValueError(