本文整理汇总了Python中matplotlib.artist方法的典型用法代码示例。如果您正苦于以下问题:Python matplotlib.artist方法的具体用法?Python matplotlib.artist怎么用?Python matplotlib.artist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib
的用法示例。
在下文中一共展示了matplotlib.artist方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_artist
# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import artist [as 别名]
def add_artist(self, a):
"""Add any :class:`~matplotlib.artist.Artist` to the axes.
Use `add_artist` only for artists for which there is no dedicated
"add" method; and if necessary, use a method such as
`update_datalim` or `update_datalim_numerix` to manually update the
dataLim if the artist is to be included in autoscaling.
Returns the artist.
"""
a.set_axes(self)
self.artists.append(a)
self._set_artist_props(a)
a.set_clip_path(self.patch)
a._remove_method = lambda h: self.artists.remove(h)
return a
示例2: add_artist
# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import artist [as 别名]
def add_artist(self, a):
"""Add any :class:`~matplotlib.artist.Artist` to the axes.
Use `add_artist` only for artists for which there is no dedicated
"add" method; and if necessary, use a method such as `update_datalim`
to manually update the dataLim if the artist is to be included in
autoscaling.
If no ``transform`` has been specified when creating the artist (e.g.
``artist.get_transform() == None``) then the transform is set to
``ax.transData``.
Returns the artist.
"""
a.axes = self
self.artists.append(a)
a._remove_method = self.artists.remove
self._set_artist_props(a)
a.set_clip_path(self.patch)
self.stale = True
return a
示例3: gci
# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import artist [as 别名]
def gci():
"""
Get the current colorable artist. Specifically, returns the
current :class:`~matplotlib.cm.ScalarMappable` instance (image or
patch collection), or *None* if no images or patch collections
have been defined. The commands :func:`~matplotlib.pyplot.imshow`
and :func:`~matplotlib.pyplot.figimage` create
:class:`~matplotlib.image.Image` instances, and the commands
:func:`~matplotlib.pyplot.pcolor` and
:func:`~matplotlib.pyplot.scatter` create
:class:`~matplotlib.collections.Collection` instances. The
current image is an attribute of the current axes, or the nearest
earlier axes in the current figure that contains an image.
"""
return gcf()._gci()
## Any Artist ##
# (getp is simply imported)
示例4: get_default_bbox_extra_artists
# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import artist [as 别名]
def get_default_bbox_extra_artists(self):
"""
Return a default list of artists that are used for the bounding box
calculation.
Artists are excluded either by not being visible or
``artist.set_in_layout(False)``.
"""
artists = self.get_children()
if not (self.axison and self._frameon):
# don't do bbox on spines if frame not on.
for spine in self.spines.values():
artists.remove(spine)
if not self.axison:
for _axis in self._get_axis_list():
artists.remove(_axis)
return [artist for artist in artists
if (artist.get_visible() and artist.get_in_layout())]
示例5: set_alpha
# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import artist [as 别名]
def set_alpha(self, alpha):
"""
Set the alpha tranparencies of the collection. *alpha* must be
a float or *None*.
ACCEPTS: float or None
"""
if alpha is not None:
try:
float(alpha)
except TypeError:
raise TypeError('alpha must be a float or None')
artist.Artist.set_alpha(self, alpha)
try:
self._facecolors = mcolors.colorConverter.to_rgba_array(
self._facecolors3d, self._alpha)
except (AttributeError, TypeError, IndexError):
pass
try:
self._edgecolors = mcolors.colorConverter.to_rgba_array(
self._edgecolors3d, self._alpha)
except (AttributeError, TypeError, IndexError):
pass
示例6: add_artist
# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import artist [as 别名]
def add_artist(self, a):
"""Add any :class:`~matplotlib.artist.Artist` to the axes.
Use `add_artist` only for artists for which there is no dedicated
"add" method; and if necessary, use a method such as `update_datalim`
to manually update the dataLim if the artist is to be included in
autoscaling.
Returns the artist.
"""
a.axes = self
self.artists.append(a)
self._set_artist_props(a)
a.set_clip_path(self.patch)
a._remove_method = lambda h: self.artists.remove(h)
self.stale = True
return a
示例7: print_figure
# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import artist [as 别名]
def print_figure(self, filename, *args, **kwargs):
# Use pure Agg renderer to draw
FigureCanvasBase.print_figure(self, filename, *args, **kwargs)
# Restore the current view; this is needed because the
# artist contains methods rely on particular attributes
# of the rendered figure for determining things like
# bounding boxes.
if self._isDrawn:
self.draw()
示例8: gci
# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import artist [as 别名]
def gci():
"""
Get the current colorable artist. Specifically, returns the
current :class:`~matplotlib.cm.ScalarMappable` instance (image or
patch collection), or *None* if no images or patch collections
have been defined. The commands :func:`~matplotlib.pyplot.imshow`
and :func:`~matplotlib.pyplot.figimage` create
:class:`~matplotlib.image.Image` instances, and the commands
:func:`~matplotlib.pyplot.pcolor` and
:func:`~matplotlib.pyplot.scatter` create
:class:`~matplotlib.collections.Collection` instances. The
current image is an attribute of the current axes, or the nearest
earlier axes in the current figure that contains an image.
"""
return gcf()._gci()
示例9: __setstate__
# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import artist [as 别名]
def __setstate__(self, state):
self.__dict__ = state
# put the _remove_method back on all artists contained within the axes
for container_name in ['lines', 'collections', 'tables', 'patches',
'texts', 'images']:
container = getattr(self, container_name)
for artist in container:
artist._remove_method = container.remove
示例10: autoscale
# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import artist [as 别名]
def autoscale(self, enable=True, axis='both', tight=None):
"""
Autoscale the axis view to the data (toggle).
Convenience method for simple axis view autoscaling.
It turns autoscaling on or off, and then,
if autoscaling for either axis is on, it performs
the autoscaling on the specified axis or axes.
*enable*: [True | False | None]
True (default) turns autoscaling on, False turns it off.
None leaves the autoscaling state unchanged.
*axis*: ['x' | 'y' | 'both']
which axis to operate on; default is 'both'
*tight*: [True | False | None]
If True, set view limits to data limits;
if False, let the locator and margins expand the view limits;
if None, use tight scaling if the only artist is an image,
otherwise treat *tight* as False.
The *tight* setting is retained for future autoscaling
until it is explicitly changed.
Returns None.
"""
if enable is None:
scalex = True
scaley = True
else:
scalex = False
scaley = False
if axis in ['x', 'both']:
self._autoscaleXon = bool(enable)
scalex = self._autoscaleXon
if axis in ['y', 'both']:
self._autoscaleYon = bool(enable)
scaley = self._autoscaleYon
self.autoscale_view(tight=tight, scalex=scalex, scaley=scaley)
示例11: get_default_bbox_extra_artists
# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import artist [as 别名]
def get_default_bbox_extra_artists(self):
return [artist for artist in self.get_children()
if artist.get_visible()]
示例12: pick
# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import artist [as 别名]
def pick(self, *args):
"""Trigger pick event
Call signature::
pick(mouseevent)
each child artist will fire a pick event if mouseevent is over
the artist and the artist has picker set
"""
martist.Artist.pick(self, args[0])
示例13: get_default_bbox_extra_artists
# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import artist [as 别名]
def get_default_bbox_extra_artists(self):
"""
Return a default list of artists that are used for the bounding box
calculation.
Artists are excluded either by not being visible or
``artist.set_in_layout(False)``.
"""
return [artist for artist in self.get_children()
if (artist.get_visible() and artist.get_in_layout())]
示例14: gci
# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import artist [as 别名]
def gci():
"""
Get the current colorable artist. Specifically, returns the
current :class:`~matplotlib.cm.ScalarMappable` instance (image or
patch collection), or *None* if no images or patch collections
have been defined. The commands :func:`~matplotlib.pyplot.imshow`
and :func:`~matplotlib.pyplot.figimage` create
:class:`~matplotlib.image.Image` instances, and the commands
:func:`~matplotlib.pyplot.pcolor` and
:func:`~matplotlib.pyplot.scatter` create
:class:`~matplotlib.collections.Collection` instances. The
current image is an attribute of the current axes, or the nearest
earlier axes in the current figure that contains an image.
Notes
-----
Historically, the only colorable artists were images; hence the name
``gci`` (get current image).
"""
return gcf()._gci()
## Any Artist ##
# (getp is simply imported)