當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。