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


Python FigureCanvasAgg.draw方法代码示例

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


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

示例1: _render_figure

# 需要导入模块: from matplotlib.backends.backend_agg import FigureCanvasAgg [as 别名]
# 或者: from matplotlib.backends.backend_agg.FigureCanvasAgg import draw [as 别名]
def _render_figure(self, pixmap, width, height):
        if DEBUG: print('FigureCanvasGTKAgg.render_figure')
        FigureCanvasAgg.draw(self)
        if DEBUG: print('FigureCanvasGTKAgg.render_figure pixmap', pixmap)
        #agg_to_gtk_drawable(pixmap, self.renderer._renderer, None)

        buf = self.buffer_rgba()
        ren = self.get_renderer()
        w = int(ren.width)
        h = int(ren.height)

        pixbuf = gtk.gdk.pixbuf_new_from_data(
            buf, gtk.gdk.COLORSPACE_RGB,  True, 8, w, h, w*4)
        pixmap.draw_pixbuf(pixmap.new_gc(), pixbuf, 0, 0, 0, 0, w, h,
                           gtk.gdk.RGB_DITHER_NONE, 0, 0)
        if DEBUG: print('FigureCanvasGTKAgg.render_figure done') 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:18,代码来源:backend_gtkagg.py

示例2: draw

# 需要导入模块: from matplotlib.backends.backend_agg import FigureCanvasAgg [as 别名]
# 或者: from matplotlib.backends.backend_agg.FigureCanvasAgg import draw [as 别名]
def draw(self):
        '''
        Draw the figure using the agg renderer
        '''
        self.canvas.clear()
        FigureCanvasAgg.draw(self)
        if self.blitbox is None:
            l, b, w, h = self.figure.bbox.bounds
            w, h = int(w), int(h)
            buf_rgba = self.get_renderer().buffer_rgba()
        else:
            bbox = self.blitbox
            l, b, r, t = bbox.extents
            w = int(r) - int(l)
            h = int(t) - int(b)
            t = int(b) + h
            reg = self.copy_from_bbox(bbox)
            buf_rgba = reg.to_string()
        texture = Texture.create(size=(w, h))
        texture.flip_vertical()
        color = self.figure.get_facecolor()
        with self.canvas:
            Color(*color)
            Rectangle(pos=self.pos, size=(w, h))
            Color(1.0, 1.0, 1.0, 1.0)
            self.img_rect = Rectangle(texture=texture, pos=self.pos,
                                      size=(w, h))
        texture.blit_buffer(bytes(buf_rgba), colorfmt='rgba', bufferfmt='ubyte')
        self.img_texture = texture 
开发者ID:kivy-garden,项目名称:garden.matplotlib,代码行数:31,代码来源:backend_kivyagg.py

示例3: get_graphics

# 需要导入模块: from matplotlib.backends.backend_agg import FigureCanvasAgg [as 别名]
# 或者: from matplotlib.backends.backend_agg.FigureCanvasAgg import draw [as 别名]
def get_graphics(self, gc, polygons, points_line, rgbFace, closed=False):
        '''Return an instruction group which contains the necessary graphics
           instructions to draw the respective graphics.
        '''
        instruction_group = InstructionGroup()
        if isinstance(gc.line['dash_list'], tuple):
            gc.line['dash_list'] = list(gc.line['dash_list'])
        if rgbFace is not None:
            if len(polygons.meshes) != 0:
                instruction_group.add(Color(*rgbFace))
                for vertices, indices in polygons.meshes:
                    instruction_group.add(Mesh(
                        vertices=vertices,
                        indices=indices,
                        mode=str("triangle_fan")
                    ))
        instruction_group.add(Color(*gc.get_rgb()))
        if _mpl_ge_1_5 and (not _mpl_ge_2_0) and closed:
            points_poly_line = points_line[:-2]
        else:
            points_poly_line = points_line
        if gc.line['width'] > 0:
            instruction_group.add(Line(points=points_poly_line,
                width=int(gc.line['width'] / 2),
                dash_length=gc.line['dash_length'],
                dash_offset=gc.line['dash_offset'],
                dash_joint=gc.line['join_style'],
                dash_list=gc.line['dash_list']))
        return instruction_group 
开发者ID:kivy-garden,项目名称:garden.matplotlib,代码行数:31,代码来源:backend_kivy.py

示例4: draw

# 需要导入模块: from matplotlib.backends.backend_agg import FigureCanvasAgg [as 别名]
# 或者: from matplotlib.backends.backend_agg.FigureCanvasAgg import draw [as 别名]
def draw(self):
        '''Draw the figure using the KivyRenderer
        '''
        self.clear_widgets()
        self.canvas.clear()
        self._renderer = RendererKivy(self)
        self.figure.draw(self._renderer) 
开发者ID:kivy-garden,项目名称:garden.matplotlib,代码行数:9,代码来源:backend_kivy.py

示例5: _on_pos_changed

# 需要导入模块: from matplotlib.backends.backend_agg import FigureCanvasAgg [as 别名]
# 或者: from matplotlib.backends.backend_agg.FigureCanvasAgg import draw [as 别名]
def _on_pos_changed(self, *args):
        self.draw() 
开发者ID:kivy-garden,项目名称:garden.matplotlib,代码行数:4,代码来源:backend_kivy.py

示例6: _on_size_changed

# 需要导入模块: from matplotlib.backends.backend_agg import FigureCanvasAgg [as 别名]
# 或者: from matplotlib.backends.backend_agg.FigureCanvasAgg import draw [as 别名]
def _on_size_changed(self, *args):
        '''Changes the size of the matplotlib figure based on the size of the
           widget. The widget will change size according to the parent Layout
           size.
        '''
        w, h = self.size
        dpival = self.figure.dpi
        winch = float(w) / dpival
        hinch = float(h) / dpival
        self.figure.set_size_inches(winch, hinch, forward=False)
        self.resize_event()
        self.draw() 
开发者ID:kivy-garden,项目名称:garden.matplotlib,代码行数:14,代码来源:backend_kivy.py

示例7: print_png

# 需要导入模块: from matplotlib.backends.backend_agg import FigureCanvasAgg [as 别名]
# 或者: from matplotlib.backends.backend_agg.FigureCanvasAgg import draw [as 别名]
def print_png(self, filename, *args, **kwargs):
        '''Call the widget function to make a png of the widget.
        '''
        fig = FigureCanvasAgg(self.figure)
        FigureCanvasAgg.draw(fig)

        l, b, w, h = self.figure.bbox.bounds
        texture = Texture.create(size=(w, h))
        texture.blit_buffer(bytes(fig.get_renderer().buffer_rgba()),
                                colorfmt='rgba', bufferfmt='ubyte')
        texture.flip_vertical()
        img = Image(texture)
        img.save(filename) 
开发者ID:kivy-garden,项目名称:garden.matplotlib,代码行数:15,代码来源:backend_kivy.py

示例8: draw

# 需要导入模块: from matplotlib.backends.backend_agg import FigureCanvasAgg [as 别名]
# 或者: from matplotlib.backends.backend_agg.FigureCanvasAgg import draw [as 别名]
def draw(self):
        FigureCanvasAgg.draw(self)
        tkagg.blit(self._tkphoto, self.renderer._renderer, colormode=2)
        self._master.update_idletasks() 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:6,代码来源:backend_tkagg.py

示例9: draw_idle

# 需要导入模块: from matplotlib.backends.backend_agg import FigureCanvasAgg [as 别名]
# 或者: from matplotlib.backends.backend_agg.FigureCanvasAgg import draw [as 别名]
def draw_idle(self):
        'update drawing area only if idle'
        d = self._idle
        self._idle = False
        def idle_draw(*args):
            self.draw()
            self._idle = True

        if d:
            self._idle_callback = self._tkcanvas.after_idle(idle_draw) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:12,代码来源:backend_tkagg.py

示例10: panx

# 需要导入模块: from matplotlib.backends.backend_agg import FigureCanvasAgg [as 别名]
# 或者: from matplotlib.backends.backend_agg.FigureCanvasAgg import draw [as 别名]
def panx(self, direction):
        for a in self._active:
            a.xaxis.pan(direction)
        self.canvas.draw() 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:6,代码来源:backend_tkagg.py

示例11: pany

# 需要导入模块: from matplotlib.backends.backend_agg import FigureCanvasAgg [as 别名]
# 或者: from matplotlib.backends.backend_agg.FigureCanvasAgg import draw [as 别名]
def pany(self, direction):
        for a in self._active:
            a.yaxis.pan(direction)
        self.canvas.draw() 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:6,代码来源:backend_tkagg.py

示例12: zoomx

# 需要导入模块: from matplotlib.backends.backend_agg import FigureCanvasAgg [as 别名]
# 或者: from matplotlib.backends.backend_agg.FigureCanvasAgg import draw [as 别名]
def zoomx(self, direction):

        for a in self._active:
            a.xaxis.zoom(direction)
        self.canvas.draw() 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:7,代码来源:backend_tkagg.py

示例13: draw_rubberband

# 需要导入模块: from matplotlib.backends.backend_agg import FigureCanvasAgg [as 别名]
# 或者: from matplotlib.backends.backend_agg.FigureCanvasAgg import draw [as 别名]
def draw_rubberband(self, event, x0, y0, x1, y1):
        height = self.canvas.figure.bbox.height
        y0 =  height-y0
        y1 =  height-y1
        try: self.lastrect
        except AttributeError: pass
        else: self.canvas._tkcanvas.delete(self.lastrect)
        self.lastrect = self.canvas._tkcanvas.create_rectangle(x0, y0, x1, y1)

        #self.canvas.draw() 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:12,代码来源:backend_tkagg.py

示例14: draw_idle

# 需要导入模块: from matplotlib.backends.backend_agg import FigureCanvasAgg [as 别名]
# 或者: from matplotlib.backends.backend_agg.FigureCanvasAgg import draw [as 别名]
def draw_idle(self):
        'update drawing area only if idle'
        d = self._idle
        self._idle = False
        def idle_draw(*args):
            try:
                self.draw()
            finally:
                self._idle = True

        if d:
            self._idle_callback = self._tkcanvas.after_idle(idle_draw) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:14,代码来源:backend_tkagg.py

示例15: draw

# 需要导入模块: from matplotlib.backends.backend_agg import FigureCanvasAgg [as 别名]
# 或者: from matplotlib.backends.backend_agg.FigureCanvasAgg import draw [as 别名]
def draw(self):
        """
        Draw the figure with Agg, and queue a request for a Qt draw.
        """
        # The Agg draw is done here; delaying causes problems with code that
        # uses the result of the draw() to update plot elements.
        FigureCanvasAgg.draw(self)
        self.update() 
开发者ID:fcollonval,项目名称:matplotlib_qtquick_playground,代码行数:10,代码来源:backend_qquick5agg.py


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