當前位置: 首頁>>代碼示例>>Python>>正文


Python patheffects.PathEffectRenderer方法代碼示例

本文整理匯總了Python中matplotlib.patheffects.PathEffectRenderer方法的典型用法代碼示例。如果您正苦於以下問題:Python patheffects.PathEffectRenderer方法的具體用法?Python patheffects.PathEffectRenderer怎麽用?Python patheffects.PathEffectRenderer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在matplotlib.patheffects的用法示例。


在下文中一共展示了patheffects.PathEffectRenderer方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_PathEffect_points_to_pixels

# 需要導入模塊: from matplotlib import patheffects [as 別名]
# 或者: from matplotlib.patheffects import PathEffectRenderer [as 別名]
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)) 
開發者ID:miloharper,項目名稱:neural-network-animation,代碼行數:19,代碼來源:test_patheffects.py

示例2: test_PathEffect_points_to_pixels

# 需要導入模塊: from matplotlib import patheffects [as 別名]
# 或者: from matplotlib.patheffects import PathEffectRenderer [as 別名]
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) 
開發者ID:holzschu,項目名稱:python3_ios,代碼行數:15,代碼來源:test_patheffects.py

示例3: _bind_draw_path_function

# 需要導入模塊: from matplotlib import patheffects [as 別名]
# 或者: from matplotlib.patheffects import PathEffectRenderer [as 別名]
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 
開發者ID:PacktPublishing,項目名稱:Mastering-Elasticsearch-7.0,代碼行數:59,代碼來源:patches.py

示例4: draw

# 需要導入模塊: from matplotlib import patheffects [as 別名]
# 或者: from matplotlib.patheffects import PathEffectRenderer [as 別名]
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') 
開發者ID:miloharper,項目名稱:neural-network-animation,代碼行數:50,代碼來源:patches.py

示例5: draw

# 需要導入模塊: from matplotlib import patheffects [as 別名]
# 或者: from matplotlib.patheffects import PathEffectRenderer [as 別名]
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 
開發者ID:Relph1119,項目名稱:GraphicDesignPatternByPython,代碼行數:57,代碼來源:patches.py

示例6: draw

# 需要導入模塊: from matplotlib import patheffects [as 別名]
# 或者: from matplotlib.patheffects import PathEffectRenderer [as 別名]
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 
開發者ID:alvarobartt,項目名稱:twitter-stock-recommendation,代碼行數:57,代碼來源:patches.py


注:本文中的matplotlib.patheffects.PathEffectRenderer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。