Python matplotlib.artist() Examples
The following are 30 code examples for showing how to use matplotlib.artist(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.
You may check out the related API usage on the sidebar.
You may also want to check out all available functions/classes of the module
matplotlib
, or try the search function
.
Example 1
Project: neural-network-animation Author: miloharper File: _base.py License: MIT License | 6 votes |
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
Example 2
Project: GraphicDesignPatternByPython Author: Relph1119 File: _base.py License: MIT License | 6 votes |
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
Example 3
Project: GraphicDesignPatternByPython Author: Relph1119 File: pyplot.py License: MIT License | 6 votes |
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)
Example 4
Project: python3_ios Author: holzschu File: _base.py License: BSD 3-Clause "New" or "Revised" License | 6 votes |
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
Example 5
Project: python3_ios Author: holzschu File: _base.py License: BSD 3-Clause "New" or "Revised" License | 6 votes |
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())]
Example 6
Project: python3_ios Author: holzschu File: pyplot.py License: BSD 3-Clause "New" or "Revised" License | 6 votes |
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)
Example 7
Project: opticspy Author: Sterncat File: art3d.py License: MIT License | 6 votes |
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
Example 8
Project: ImageFusion Author: pfchai File: _base.py License: MIT License | 6 votes |
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
Example 9
Project: coffeegrindsize Author: jgagneastro File: _base.py License: MIT License | 6 votes |
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
Example 10
Project: coffeegrindsize Author: jgagneastro File: _base.py License: MIT License | 6 votes |
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())]
Example 11
Project: coffeegrindsize Author: jgagneastro File: pyplot.py License: MIT License | 6 votes |
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)
Example 12
Project: twitter-stock-recommendation Author: alvarobartt File: _base.py License: MIT License | 6 votes |
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
Example 13
Project: Computable Author: ktraunmueller File: backend_wx.py License: MIT License | 5 votes |
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()
Example 14
Project: Computable Author: ktraunmueller File: pyplot.py License: MIT License | 5 votes |
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()
Example 15
Project: matplotlib-4-abaqus Author: Solid-Mechanics File: backend_wx.py License: MIT License | 5 votes |
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()
Example 16
Project: matplotlib-4-abaqus Author: Solid-Mechanics File: pyplot.py License: MIT License | 5 votes |
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()
Example 17
Project: neural-network-animation Author: miloharper File: backend_wx.py License: MIT License | 5 votes |
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()
Example 18
Project: neural-network-animation Author: miloharper File: _base.py License: MIT License | 5 votes |
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
Example 19
Project: neural-network-animation Author: miloharper File: _base.py License: MIT License | 5 votes |
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)
Example 20
Project: neural-network-animation Author: miloharper File: _base.py License: MIT License | 5 votes |
def get_default_bbox_extra_artists(self): return [artist for artist in self.get_children() if artist.get_visible()]
Example 21
Project: neural-network-animation Author: miloharper File: pyplot.py License: MIT License | 5 votes |
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()
Example 22
Project: GraphicDesignPatternByPython Author: Relph1119 File: _base.py License: MIT License | 5 votes |
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])
Example 23
Project: GraphicDesignPatternByPython Author: Relph1119 File: _base.py License: MIT License | 5 votes |
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())]
Example 24
Project: python3_ios Author: holzschu File: _base.py License: BSD 3-Clause "New" or "Revised" License | 5 votes |
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])
Example 25
Project: ImageFusion Author: pfchai File: backend_wx.py License: MIT License | 5 votes |
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()
Example 26
Project: ImageFusion Author: pfchai File: _base.py License: MIT License | 5 votes |
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
Example 27
Project: ImageFusion Author: pfchai File: _base.py License: MIT License | 5 votes |
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)
Example 28
Project: ImageFusion Author: pfchai File: _base.py License: MIT License | 5 votes |
def get_default_bbox_extra_artists(self): return [artist for artist in self.get_children() if artist.get_visible()]
Example 29
Project: coffeegrindsize Author: jgagneastro File: _base.py License: MIT License | 5 votes |
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])
Example 30
Project: CogAlg Author: boris-kz File: pyplot.py License: MIT License | 5 votes |
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)