Python matplotlib.patheffects.PathEffectRenderer() Examples
The following are 15
code examples of matplotlib.patheffects.PathEffectRenderer().
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 also want to check out all available functions/classes of the module
matplotlib.patheffects
, or try the search function
.
Example #1
Source File: test_patheffects.py From neural-network-animation with MIT License | 6 votes |
def test_PathEffect_points_to_pixels(): fig = plt.figure(dpi=150) p1, = plt.plot(range(10)) p1.set_path_effects([path_effects.SimpleLineShadow(), path_effects.Normal()]) renderer = fig.canvas.get_renderer() pe_renderer = path_effects.SimpleLineShadow().get_proxy_renderer(renderer) assert isinstance(pe_renderer, path_effects.PathEffectRenderer), ( 'Expected a PathEffectRendere instance, got ' 'a {} instance.'.format(type(pe_renderer))) # Confirm that using a path effects renderer maintains point sizes # appropriately. Otherwise rendered font would be the wrong size. assert_equal(renderer.points_to_pixels(15), pe_renderer.points_to_pixels(15))
Example #2
Source File: test_patheffects.py From ImageFusion with MIT License | 6 votes |
def test_PathEffect_points_to_pixels(): fig = plt.figure(dpi=150) p1, = plt.plot(range(10)) p1.set_path_effects([path_effects.SimpleLineShadow(), path_effects.Normal()]) renderer = fig.canvas.get_renderer() pe_renderer = path_effects.SimpleLineShadow().get_proxy_renderer(renderer) assert isinstance(pe_renderer, path_effects.PathEffectRenderer), ( 'Expected a PathEffectRendere instance, got ' 'a {} instance.'.format(type(pe_renderer))) # Confirm that using a path effects renderer maintains point sizes # appropriately. Otherwise rendered font would be the wrong size. assert_equal(renderer.points_to_pixels(15), pe_renderer.points_to_pixels(15))
Example #3
Source File: test_patheffects.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_PathEffect_points_to_pixels(): fig = plt.figure(dpi=150) p1, = plt.plot(range(10)) p1.set_path_effects([path_effects.SimpleLineShadow(), path_effects.Normal()]) renderer = fig.canvas.get_renderer() pe_renderer = path_effects.SimpleLineShadow().get_proxy_renderer(renderer) assert isinstance(pe_renderer, path_effects.PathEffectRenderer) # Confirm that using a path effects renderer maintains point sizes # appropriately. Otherwise rendered font would be the wrong size. assert renderer.points_to_pixels(15) == pe_renderer.points_to_pixels(15)
Example #4
Source File: test_patheffects.py From coffeegrindsize with MIT License | 5 votes |
def test_PathEffect_points_to_pixels(): fig = plt.figure(dpi=150) p1, = plt.plot(range(10)) p1.set_path_effects([path_effects.SimpleLineShadow(), path_effects.Normal()]) renderer = fig.canvas.get_renderer() pe_renderer = path_effects.SimpleLineShadow().get_proxy_renderer(renderer) assert isinstance(pe_renderer, path_effects.PathEffectRenderer) # Confirm that using a path effects renderer maintains point sizes # appropriately. Otherwise rendered font would be the wrong size. assert renderer.points_to_pixels(15) == pe_renderer.points_to_pixels(15)
Example #5
Source File: test_patheffects.py From twitter-stock-recommendation with MIT License | 5 votes |
def test_PathEffect_points_to_pixels(): fig = plt.figure(dpi=150) p1, = plt.plot(range(10)) p1.set_path_effects([path_effects.SimpleLineShadow(), path_effects.Normal()]) renderer = fig.canvas.get_renderer() pe_renderer = path_effects.SimpleLineShadow().get_proxy_renderer(renderer) assert isinstance(pe_renderer, path_effects.PathEffectRenderer) # Confirm that using a path effects renderer maintains point sizes # appropriately. Otherwise rendered font would be the wrong size. assert renderer.points_to_pixels(15) == pe_renderer.points_to_pixels(15)
Example #6
Source File: patches.py From Mastering-Elasticsearch-7.0 with MIT License | 4 votes |
def _bind_draw_path_function(self, renderer): """ ``draw()`` helper factored out for sharing with `FancyArrowPatch`. Yields a callable ``dp`` such that calling ``dp(*args, **kwargs)`` is equivalent to calling ``renderer1.draw_path(gc, *args, **kwargs)`` where ``renderer1`` and ``gc`` have been suitably set from ``renderer`` and the artist's properties. """ renderer.open_group('patch', self.get_gid()) gc = renderer.new_gc() gc.set_foreground(self._edgecolor, isRGBA=True) lw = self._linewidth if self._edgecolor[3] == 0: lw = 0 gc.set_linewidth(lw) gc.set_dashes(self._dashoffset, self._dashes) gc.set_capstyle(self._capstyle) gc.set_joinstyle(self._joinstyle) gc.set_antialiased(self._antialiased) self._set_gc_clip(gc) gc.set_url(self._url) gc.set_snap(self.get_snap()) gc.set_alpha(self._alpha) if self._hatch: gc.set_hatch(self._hatch) try: gc.set_hatch_color(self._hatch_color) except AttributeError: # if we end up with a GC that does not have this method cbook.warn_deprecated( "3.1", message="Your backend does not support setting the " "hatch color; such backends will become unsupported in " "Matplotlib 3.3.") if self.get_sketch_params() is not None: gc.set_sketch_params(*self.get_sketch_params()) if self.get_path_effects(): from matplotlib.patheffects import PathEffectRenderer renderer = PathEffectRenderer(self.get_path_effects(), renderer) # In `with _bind_draw_path_function(renderer) as draw_path: ...` # (in the implementations of `draw()` below), calls to `draw_path(...)` # will occur as if they took place here with `gc` inserted as # additional first argument. yield functools.partial(renderer.draw_path, gc) gc.restore() renderer.close_group('patch') self.stale = False
Example #7
Source File: patches.py From neural-network-animation with MIT License | 4 votes |
def draw(self, renderer): 'Draw the :class:`Patch` to the given *renderer*.' if not self.get_visible(): return renderer.open_group('patch', self.get_gid()) gc = renderer.new_gc() gc.set_foreground(self._edgecolor, isRGBA=True) lw = self._linewidth if self._edgecolor[3] == 0: lw = 0 gc.set_linewidth(lw) gc.set_linestyle(self._linestyle) gc.set_capstyle(self._capstyle) gc.set_joinstyle(self._joinstyle) gc.set_antialiased(self._antialiased) self._set_gc_clip(gc) gc.set_url(self._url) gc.set_snap(self.get_snap()) rgbFace = self._facecolor if rgbFace[3] == 0: rgbFace = None # (some?) renderers expect this as no-fill signal gc.set_alpha(self._alpha) if self._hatch: gc.set_hatch(self._hatch) if self.get_sketch_params() is not None: gc.set_sketch_params(*self.get_sketch_params()) path = self.get_path() transform = self.get_transform() tpath = transform.transform_path_non_affine(path) affine = transform.get_affine() if self.get_path_effects(): from matplotlib.patheffects import PathEffectRenderer renderer = PathEffectRenderer(self.get_path_effects(), renderer) renderer.draw_path(gc, tpath, affine, rgbFace) gc.restore() renderer.close_group('patch')
Example #8
Source File: patches.py From neural-network-animation with MIT License | 4 votes |
def draw(self, renderer): if not self.get_visible(): return renderer.open_group('patch', self.get_gid()) gc = renderer.new_gc() gc.set_foreground(self._edgecolor, isRGBA=True) lw = self._linewidth if self._edgecolor[3] == 0: lw = 0 gc.set_linewidth(lw) gc.set_linestyle(self._linestyle) gc.set_antialiased(self._antialiased) self._set_gc_clip(gc) gc.set_capstyle('round') gc.set_snap(self.get_snap()) rgbFace = self._facecolor if rgbFace[3] == 0: rgbFace = None # (some?) renderers expect this as no-fill signal gc.set_alpha(self._alpha) if self._hatch: gc.set_hatch(self._hatch) if self.get_sketch_params() is not None: gc.set_sketch_params(*self.get_sketch_params()) # FIXME : dpi_cor is for the dpi-dependecy of the # linewidth. There could be room for improvement. # #dpi_cor = renderer.points_to_pixels(1.) self.set_dpi_cor(renderer.points_to_pixels(1.)) path, fillable = self.get_path_in_displaycoord() if not cbook.iterable(fillable): path = [path] fillable = [fillable] affine = transforms.IdentityTransform() if self.get_path_effects(): from matplotlib.patheffects import PathEffectRenderer renderer = PathEffectRenderer(self.get_path_effects(), renderer) for p, f in zip(path, fillable): if f: renderer.draw_path(gc, p, affine, rgbFace) else: renderer.draw_path(gc, p, affine, None) gc.restore() renderer.close_group('patch')
Example #9
Source File: patches.py From GraphicDesignPatternByPython with MIT License | 4 votes |
def draw(self, renderer): 'Draw the :class:`Patch` to the given *renderer*.' if not self.get_visible(): return renderer.open_group('patch', self.get_gid()) gc = renderer.new_gc() gc.set_foreground(self._edgecolor, isRGBA=True) lw = self._linewidth if self._edgecolor[3] == 0: lw = 0 gc.set_linewidth(lw) gc.set_dashes(0, self._dashes) gc.set_capstyle(self._capstyle) gc.set_joinstyle(self._joinstyle) gc.set_antialiased(self._antialiased) self._set_gc_clip(gc) gc.set_url(self._url) gc.set_snap(self.get_snap()) rgbFace = self._facecolor if rgbFace[3] == 0: rgbFace = None # (some?) renderers expect this as no-fill signal gc.set_alpha(self._alpha) if self._hatch: gc.set_hatch(self._hatch) try: gc.set_hatch_color(self._hatch_color) except AttributeError: # if we end up with a GC that does not have this method warnings.warn( "Your backend does not support setting the hatch color.") if self.get_sketch_params() is not None: gc.set_sketch_params(*self.get_sketch_params()) path = self.get_path() transform = self.get_transform() tpath = transform.transform_path_non_affine(path) affine = transform.get_affine() if self.get_path_effects(): from matplotlib.patheffects import PathEffectRenderer renderer = PathEffectRenderer(self.get_path_effects(), renderer) renderer.draw_path(gc, tpath, affine, rgbFace) gc.restore() renderer.close_group('patch') self.stale = False
Example #10
Source File: patches.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 4 votes |
def draw(self, renderer): 'Draw the :class:`Patch` to the given *renderer*.' if not self.get_visible(): return renderer.open_group('patch', self.get_gid()) gc = renderer.new_gc() gc.set_foreground(self._edgecolor, isRGBA=True) lw = self._linewidth if self._edgecolor[3] == 0: lw = 0 gc.set_linewidth(lw) gc.set_dashes(0, self._dashes) gc.set_capstyle(self._capstyle) gc.set_joinstyle(self._joinstyle) gc.set_antialiased(self._antialiased) self._set_gc_clip(gc) gc.set_url(self._url) gc.set_snap(self.get_snap()) rgbFace = self._facecolor if rgbFace[3] == 0: rgbFace = None # (some?) renderers expect this as no-fill signal gc.set_alpha(self._alpha) if self._hatch: gc.set_hatch(self._hatch) try: gc.set_hatch_color(self._hatch_color) except AttributeError: # if we end up with a GC that does not have this method warnings.warn( "Your backend does not support setting the hatch color.") if self.get_sketch_params() is not None: gc.set_sketch_params(*self.get_sketch_params()) path = self.get_path() transform = self.get_transform() tpath = transform.transform_path_non_affine(path) affine = transform.get_affine() if self.get_path_effects(): from matplotlib.patheffects import PathEffectRenderer renderer = PathEffectRenderer(self.get_path_effects(), renderer) renderer.draw_path(gc, tpath, affine, rgbFace) gc.restore() renderer.close_group('patch') self.stale = False
Example #11
Source File: patches.py From ImageFusion with MIT License | 4 votes |
def draw(self, renderer): 'Draw the :class:`Patch` to the given *renderer*.' if not self.get_visible(): return renderer.open_group('patch', self.get_gid()) gc = renderer.new_gc() gc.set_foreground(self._edgecolor, isRGBA=True) lw = self._linewidth if self._edgecolor[3] == 0: lw = 0 gc.set_linewidth(lw) gc.set_linestyle(self._linestyle) gc.set_capstyle(self._capstyle) gc.set_joinstyle(self._joinstyle) gc.set_antialiased(self._antialiased) self._set_gc_clip(gc) gc.set_url(self._url) gc.set_snap(self.get_snap()) rgbFace = self._facecolor if rgbFace[3] == 0: rgbFace = None # (some?) renderers expect this as no-fill signal gc.set_alpha(self._alpha) if self._hatch: gc.set_hatch(self._hatch) if self.get_sketch_params() is not None: gc.set_sketch_params(*self.get_sketch_params()) path = self.get_path() transform = self.get_transform() tpath = transform.transform_path_non_affine(path) affine = transform.get_affine() if self.get_path_effects(): from matplotlib.patheffects import PathEffectRenderer renderer = PathEffectRenderer(self.get_path_effects(), renderer) renderer.draw_path(gc, tpath, affine, rgbFace) gc.restore() renderer.close_group('patch')
Example #12
Source File: patches.py From ImageFusion with MIT License | 4 votes |
def draw(self, renderer): if not self.get_visible(): return renderer.open_group('patch', self.get_gid()) gc = renderer.new_gc() gc.set_foreground(self._edgecolor, isRGBA=True) lw = self._linewidth if self._edgecolor[3] == 0: lw = 0 gc.set_linewidth(lw) gc.set_linestyle(self._linestyle) gc.set_antialiased(self._antialiased) self._set_gc_clip(gc) gc.set_capstyle('round') gc.set_snap(self.get_snap()) rgbFace = self._facecolor if rgbFace[3] == 0: rgbFace = None # (some?) renderers expect this as no-fill signal gc.set_alpha(self._alpha) if self._hatch: gc.set_hatch(self._hatch) if self.get_sketch_params() is not None: gc.set_sketch_params(*self.get_sketch_params()) # FIXME : dpi_cor is for the dpi-dependecy of the # linewidth. There could be room for improvement. # #dpi_cor = renderer.points_to_pixels(1.) self.set_dpi_cor(renderer.points_to_pixels(1.)) path, fillable = self.get_path_in_displaycoord() if not cbook.iterable(fillable): path = [path] fillable = [fillable] affine = transforms.IdentityTransform() if self.get_path_effects(): from matplotlib.patheffects import PathEffectRenderer renderer = PathEffectRenderer(self.get_path_effects(), renderer) for p, f in zip(path, fillable): if f: renderer.draw_path(gc, p, affine, rgbFace) else: renderer.draw_path(gc, p, affine, None) gc.restore() renderer.close_group('patch')
Example #13
Source File: patches.py From coffeegrindsize with MIT License | 4 votes |
def draw(self, renderer): 'Draw the :class:`Patch` to the given *renderer*.' if not self.get_visible(): return renderer.open_group('patch', self.get_gid()) gc = renderer.new_gc() gc.set_foreground(self._edgecolor, isRGBA=True) lw = self._linewidth if self._edgecolor[3] == 0: lw = 0 gc.set_linewidth(lw) gc.set_dashes(0, self._dashes) gc.set_capstyle(self._capstyle) gc.set_joinstyle(self._joinstyle) gc.set_antialiased(self._antialiased) self._set_gc_clip(gc) gc.set_url(self._url) gc.set_snap(self.get_snap()) rgbFace = self._facecolor if rgbFace[3] == 0: rgbFace = None # (some?) renderers expect this as no-fill signal gc.set_alpha(self._alpha) if self._hatch: gc.set_hatch(self._hatch) try: gc.set_hatch_color(self._hatch_color) except AttributeError: # if we end up with a GC that does not have this method warnings.warn( "Your backend does not support setting the hatch color.") if self.get_sketch_params() is not None: gc.set_sketch_params(*self.get_sketch_params()) path = self.get_path() transform = self.get_transform() tpath = transform.transform_path_non_affine(path) affine = transform.get_affine() if self.get_path_effects(): from matplotlib.patheffects import PathEffectRenderer renderer = PathEffectRenderer(self.get_path_effects(), renderer) renderer.draw_path(gc, tpath, affine, rgbFace) gc.restore() renderer.close_group('patch') self.stale = False
Example #14
Source File: patches.py From CogAlg with MIT License | 4 votes |
def _bind_draw_path_function(self, renderer): """ ``draw()`` helper factored out for sharing with `FancyArrowPatch`. Yields a callable ``dp`` such that calling ``dp(*args, **kwargs)`` is equivalent to calling ``renderer1.draw_path(gc, *args, **kwargs)`` where ``renderer1`` and ``gc`` have been suitably set from ``renderer`` and the artist's properties. """ renderer.open_group('patch', self.get_gid()) gc = renderer.new_gc() gc.set_foreground(self._edgecolor, isRGBA=True) lw = self._linewidth if self._edgecolor[3] == 0: lw = 0 gc.set_linewidth(lw) gc.set_dashes(self._dashoffset, self._dashes) gc.set_capstyle(self._capstyle) gc.set_joinstyle(self._joinstyle) gc.set_antialiased(self._antialiased) self._set_gc_clip(gc) gc.set_url(self._url) gc.set_snap(self.get_snap()) gc.set_alpha(self._alpha) if self._hatch: gc.set_hatch(self._hatch) try: gc.set_hatch_color(self._hatch_color) except AttributeError: # if we end up with a GC that does not have this method cbook.warn_deprecated( "3.1", message="Your backend does not support setting the " "hatch color; such backends will become unsupported in " "Matplotlib 3.3.") if self.get_sketch_params() is not None: gc.set_sketch_params(*self.get_sketch_params()) if self.get_path_effects(): from matplotlib.patheffects import PathEffectRenderer renderer = PathEffectRenderer(self.get_path_effects(), renderer) # In `with _bind_draw_path_function(renderer) as draw_path: ...` # (in the implementations of `draw()` below), calls to `draw_path(...)` # will occur as if they took place here with `gc` inserted as # additional first argument. yield functools.partial(renderer.draw_path, gc) gc.restore() renderer.close_group('patch') self.stale = False
Example #15
Source File: patches.py From twitter-stock-recommendation with MIT License | 4 votes |
def draw(self, renderer): 'Draw the :class:`Patch` to the given *renderer*.' if not self.get_visible(): return renderer.open_group('patch', self.get_gid()) gc = renderer.new_gc() gc.set_foreground(self._edgecolor, isRGBA=True) lw = self._linewidth if self._edgecolor[3] == 0: lw = 0 gc.set_linewidth(lw) gc.set_dashes(0, self._dashes) gc.set_capstyle(self._capstyle) gc.set_joinstyle(self._joinstyle) gc.set_antialiased(self._antialiased) self._set_gc_clip(gc) gc.set_url(self._url) gc.set_snap(self.get_snap()) rgbFace = self._facecolor if rgbFace[3] == 0: rgbFace = None # (some?) renderers expect this as no-fill signal gc.set_alpha(self._alpha) if self._hatch: gc.set_hatch(self._hatch) try: gc.set_hatch_color(self._hatch_color) except AttributeError: # if we end up with a GC that does not have this method warnings.warn("Your backend does not have support for " "setting the hatch color.") if self.get_sketch_params() is not None: gc.set_sketch_params(*self.get_sketch_params()) path = self.get_path() transform = self.get_transform() tpath = transform.transform_path_non_affine(path) affine = transform.get_affine() if self.get_path_effects(): from matplotlib.patheffects import PathEffectRenderer renderer = PathEffectRenderer(self.get_path_effects(), renderer) renderer.draw_path(gc, tpath, affine, rgbFace) gc.restore() renderer.close_group('patch') self.stale = False