当前位置: 首页>>代码示例>>Python>>正文


Python backend_agg.RendererAgg方法代码示例

本文整理汇总了Python中matplotlib.backends.backend_agg.RendererAgg方法的典型用法代码示例。如果您正苦于以下问题:Python backend_agg.RendererAgg方法的具体用法?Python backend_agg.RendererAgg怎么用?Python backend_agg.RendererAgg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.backends.backend_agg的用法示例。


在下文中一共展示了backend_agg.RendererAgg方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_renderer

# 需要导入模块: from matplotlib.backends import backend_agg [as 别名]
# 或者: from matplotlib.backends.backend_agg import RendererAgg [as 别名]
def get_renderer(self, cleared=False):
        # Mirrors super.get_renderer, but caches the old one
        # so that we can do things such as prodce a diff image
        # in get_diff_image
        _, _, w, h = self.figure.bbox.bounds
        key = w, h, self.figure.dpi
        try:
            self._lastKey, self._renderer
        except AttributeError:
            need_new_renderer = True
        else:
            need_new_renderer = (self._lastKey != key)

        if need_new_renderer:
            self._renderer = backend_agg.RendererAgg(
                w, h, self.figure.dpi)
            self._last_renderer = backend_agg.RendererAgg(
                w, h, self.figure.dpi)
            self._lastKey = key

        return self._renderer 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:23,代码来源:backend_webagg.py

示例2: get_renderer

# 需要导入模块: from matplotlib.backends import backend_agg [as 别名]
# 或者: from matplotlib.backends.backend_agg import RendererAgg [as 别名]
def get_renderer(self, cleared=None):
        # Mirrors super.get_renderer, but caches the old one
        # so that we can do things such as produce a diff image
        # in get_diff_image
        _, _, w, h = self.figure.bbox.bounds
        w, h = int(w), int(h)
        key = w, h, self.figure.dpi
        try:
            self._lastKey, self._renderer
        except AttributeError:
            need_new_renderer = True
        else:
            need_new_renderer = (self._lastKey != key)

        if need_new_renderer:
            self._renderer = backend_agg.RendererAgg(
                w, h, self.figure.dpi)
            self._last_renderer = backend_agg.RendererAgg(
                w, h, self.figure.dpi)
            self._lastKey = key

        elif cleared:
            self._renderer.clear()

        return self._renderer 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:27,代码来源:backend_webagg_core.py

示例3: get_renderer

# 需要导入模块: from matplotlib.backends import backend_agg [as 别名]
# 或者: from matplotlib.backends.backend_agg import RendererAgg [as 别名]
def get_renderer(self, cleared=None):
        # Mirrors super.get_renderer, but caches the old one
        # so that we can do things such as produce a diff image
        # in get_diff_image
        _, _, w, h = self.figure.bbox.bounds
        key = w, h, self.figure.dpi
        try:
            self._lastKey, self._renderer
        except AttributeError:
            need_new_renderer = True
        else:
            need_new_renderer = (self._lastKey != key)

        if need_new_renderer:
            self._renderer = backend_agg.RendererAgg(
                w, h, self.figure.dpi)
            self._last_renderer = backend_agg.RendererAgg(
                w, h, self.figure.dpi)
            self._lastKey = key

        elif cleared:
            self._renderer.clear()

        return self._renderer 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:26,代码来源:backend_webagg_core.py

示例4: test_arrow_annotation_get_window_extent

# 需要导入模块: from matplotlib.backends import backend_agg [as 别名]
# 或者: from matplotlib.backends.backend_agg import RendererAgg [as 别名]
def test_arrow_annotation_get_window_extent():
    figure = Figure(dpi=100)
    figure.set_figwidth(2.0)
    figure.set_figheight(2.0)
    renderer = RendererAgg(200, 200, 100)

    # Text annotation with arrow
    annotation = Annotation(
        '', xy=(0.0, 50.0), xytext=(50.0, 50.0), xycoords='figure pixels',
        arrowprops={
            'facecolor': 'black', 'width': 8, 'headwidth': 10, 'shrink': 0.0})
    annotation.set_figure(figure)
    annotation.draw(renderer)

    bbox = annotation.get_window_extent()
    points = bbox.get_points()

    eq_(bbox.width, 50.0)
    assert_almost_equal(bbox.height, 10.0 / 0.72)
    eq_(points[0, 0], 0.0)
    eq_(points[0, 1], 50.0 - 5 / 0.72) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:23,代码来源:test_text.py

示例5: test_empty_annotation_get_window_extent

# 需要导入模块: from matplotlib.backends import backend_agg [as 别名]
# 或者: from matplotlib.backends.backend_agg import RendererAgg [as 别名]
def test_empty_annotation_get_window_extent():
    figure = Figure(dpi=100)
    figure.set_figwidth(2.0)
    figure.set_figheight(2.0)
    renderer = RendererAgg(200, 200, 100)

    # Text annotation with arrow
    annotation = Annotation(
        '', xy=(0.0, 50.0), xytext=(0.0, 50.0), xycoords='figure pixels')
    annotation.set_figure(figure)
    annotation.draw(renderer)

    bbox = annotation.get_window_extent()
    points = bbox.get_points()

    eq_(points[0, 0], 0.0)
    eq_(points[1, 0], 0.0)
    eq_(points[1, 1], 50.0)
    eq_(points[0, 1], 50.0) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:21,代码来源:test_text.py

示例6: draw

# 需要导入模块: from matplotlib.backends import backend_agg [as 别名]
# 或者: from matplotlib.backends.backend_agg import RendererAgg [as 别名]
def draw(self):
        # TODO: Do we just queue the drawing here?  That's what Gtk does
        renderer = self.get_renderer()

        self._png_is_old = True

        backend_agg.RendererAgg.lock.acquire()
        try:
            self.figure.draw(renderer)
        finally:
            backend_agg.RendererAgg.lock.release()
            # Swap the frames
            self.manager.refresh_all() 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:15,代码来源:backend_webagg.py

示例7: __getattr__

# 需要导入模块: from matplotlib.backends import backend_agg [as 别名]
# 或者: from matplotlib.backends.backend_agg import RendererAgg [as 别名]
def __getattr__(self, attr):
        # Proxy everything that hasn't been overridden to the base
        # renderer. Things that *are* overridden can call methods
        # on self._renderer directly, but must not cache/store
        # methods (because things like RendererAgg change their
        # methods on the fly in order to optimise proxying down
        # to the underlying C implementation).
        return getattr(self._renderer, attr) 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:10,代码来源:backend_mixed.py

示例8: draw

# 需要导入模块: from matplotlib.backends import backend_agg [as 别名]
# 或者: from matplotlib.backends.backend_agg import RendererAgg [as 别名]
def draw(self):
        renderer = self.get_renderer(cleared=True)

        self._png_is_old = True

        backend_agg.RendererAgg.lock.acquire()
        try:
            self.figure.draw(renderer)
        finally:
            backend_agg.RendererAgg.lock.release()
            # Swap the frames
            self.manager.refresh_all() 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:14,代码来源:backend_webagg_core.py

示例9: test_text_annotation_get_window_extent

# 需要导入模块: from matplotlib.backends import backend_agg [as 别名]
# 或者: from matplotlib.backends.backend_agg import RendererAgg [as 别名]
def test_text_annotation_get_window_extent():
    figure = Figure(dpi=100)
    renderer = RendererAgg(200, 200, 100)

    # Only text annotation
    annotation = Annotation('test', xy=(0, 0))
    annotation.set_figure(figure)

    text = Text(text='test', x=0, y=0)
    text.set_figure(figure)

    bbox = annotation.get_window_extent(renderer=renderer)

    text_bbox = text.get_window_extent(renderer=renderer)
    eq_(bbox.width, text_bbox.width)
    eq_(bbox.height, text_bbox.height)

    _, _, d = renderer.get_text_width_height_descent(
        'text', annotation._fontproperties, ismath=False)
    _, _, lp_d = renderer.get_text_width_height_descent(
        'lp', annotation._fontproperties, ismath=False)
    below_line = max(d, lp_d)

    # These numbers are specific to the current implementation of Text
    points = bbox.get_points()
    eq_(points[0, 0], 0.0)
    eq_(points[1, 0], text_bbox.width)
    eq_(points[0, 1], -below_line)
    eq_(points[1, 1], text_bbox.height - below_line) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:31,代码来源:test_text.py

示例10: test_renderer

# 需要导入模块: from matplotlib.backends import backend_agg [as 别名]
# 或者: from matplotlib.backends.backend_agg import RendererAgg [as 别名]
def test_renderer():
    from matplotlib.backends.backend_agg import RendererAgg
    renderer = RendererAgg(10, 20, 30)
    pickle.dump(renderer, BytesIO()) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:6,代码来源:test_pickle.py

示例11: __init__

# 需要导入模块: from matplotlib.backends import backend_agg [as 别名]
# 或者: from matplotlib.backends.backend_agg import RendererAgg [as 别名]
def __init__(self, figure, width, height, dpi, vector_renderer,
                 raster_renderer_class=None,
                 bbox_inches_restore=None):
        """
        Parameters
        ----------
        figure : `matplotlib.figure.Figure`
            The figure instance.

        width : scalar
            The width of the canvas in logical units

        height : scalar
            The height of the canvas in logical units

        dpi : scalar
            The dpi of the canvas

        vector_renderer : `matplotlib.backend_bases.RendererBase`
            An instance of a subclass of
            `~matplotlib.backend_bases.RendererBase` that will be used for the
            vector drawing.

        raster_renderer_class : `matplotlib.backend_bases.RendererBase`
            The renderer class to use for the raster drawing.  If not provided,
            this will use the Agg backend (which is currently the only viable
            option anyway.)

        """
        if raster_renderer_class is None:
            raster_renderer_class = RendererAgg

        self._raster_renderer_class = raster_renderer_class
        self._width = width
        self._height = height
        self.dpi = dpi

        self._vector_renderer = vector_renderer

        self._raster_renderer = None
        self._rasterizing = 0

        # A reference to the figure is needed as we need to change
        # the figure dpi before and after the rasterization. Although
        # this looks ugly, I couldn't find a better solution. -JJL
        self.figure = figure
        self._figdpi = figure.get_dpi()

        self._bbox_inches_restore = bbox_inches_restore

        self._renderer = vector_renderer 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:53,代码来源:backend_mixed.py


注:本文中的matplotlib.backends.backend_agg.RendererAgg方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。