本文整理汇总了Python中backend_agg.FigureCanvasAgg类的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasAgg类的具体用法?Python FigureCanvasAgg怎么用?Python FigureCanvasAgg使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FigureCanvasAgg类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mouseReleaseEvent
def mouseReleaseEvent(self, event):
x = event.x()
# flipy so y=0 is bottom of canvas
y = self.figure.bbox.height - event.y()
button = self.buttond[event.button()]
FigureCanvasAgg.button_release_event(self, x, y, button)
self.draw()
示例2: __init__
def __init__( self, figure ):
if DEBUG: print 'FigureCanvasQtAgg: ', figure
FigureCanvasQT.__init__( self, figure )
FigureCanvasAgg.__init__( self, figure )
self.drawRect = False
self.rect = []
self.replot = True
self.setAttribute(QtCore.Qt.WA_OpaquePaintEvent)
示例3: copy_from_bbox
def copy_from_bbox(self, *args):
"""
If a draw() has been called but the update() has not
occurred, draw into the agg canvas before copying.
"""
if self.replot:
FigureCanvasAgg.draw(self)
self.replot = False
return FigureCanvasAgg.copy_from_bbox(self, *args)
示例4: print_figure
def print_figure(self, filename, *args, **kwargs):
# Use pure Agg renderer to draw
FigureCanvasAgg.print_figure(self, filename, *args, **kwargs)
# Restore the current view; this is needed because the
# artist contains methods rely on particular attributes
# of the rendered figure for determining things like
# bounding boxes.
if self._isDrawn:
self.draw()
示例5: draw
def draw( self ):
"""
Draw the figure with Agg, and queue a request
for a Qt draw.
"""
# The Agg draw is done here; delaying it until the paintEvent
# causes problems with code that uses the result of the
# draw() to update plot elements.
FigureCanvasAgg.draw(self)
self.update()
示例6: draw
def draw(self, repaint=True):
"""
Render the figure using agg.
"""
DEBUG_MSG("draw()", 1, self)
FigureCanvasAgg.draw(self)
self.bitmap = _convert_agg_to_wx_bitmap(self.get_renderer(), None)
if repaint:
self.gui_repaint()
示例7: draw
def draw( self ):
"""
Draw the figure when xwindows is ready for the update
"""
if DEBUG: print "FigureCanvasQtAgg.draw", self
self.replot = True
FigureCanvasAgg.draw(self)
self.update()
# Added following line to improve realtime pan/zoom on windows:
QtGui.qApp.processEvents()
示例8: paintEvent
def paintEvent( self, e ):
"""
Draw to the Agg backend and then copy the image to the qt.drawable.
In Qt, all drawing should be done inside of here when a widget is
shown onscreen.
"""
#FigureCanvasQT.paintEvent( self, e )
if DEBUG: print 'FigureCanvasQtAgg.paintEvent: ', self, \
self.get_width_height()
# only replot data when needed
if type(self.replot) is bool: # might be a bbox for blitting
if self.replot:
FigureCanvasAgg.draw(self)
# matplotlib is in rgba byte order. QImage wants to put the bytes
# into argb format and is in a 4 byte unsigned int. Little endian
# system is LSB first and expects the bytes in reverse order
# (bgra).
if QtCore.QSysInfo.ByteOrder == QtCore.QSysInfo.LittleEndian:
stringBuffer = self.renderer._renderer.tostring_bgra()
else:
stringBuffer = self.renderer._renderer.tostring_argb()
qImage = QtGui.QImage(stringBuffer, self.renderer.width,
self.renderer.height,
QtGui.QImage.Format_ARGB32)
p = QtGui.QPainter(self)
p.drawPixmap(QtCore.QPoint(0, 0), QtGui.QPixmap.fromImage(qImage))
# draw the zoom rectangle to the QPainter
if self.drawRect:
p.setPen( QtGui.QPen( QtCore.Qt.black, 1, QtCore.Qt.DotLine ) )
p.drawRect( self.rect[0], self.rect[1], self.rect[2], self.rect[3] )
p.end()
# we are blitting here
else:
bbox = self.replot
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)
stringBuffer = reg.to_string_argb()
qImage = QtGui.QImage(stringBuffer, w, h, QtGui.QImage.Format_ARGB32)
pixmap = QtGui.QPixmap.fromImage(qImage)
p = QtGui.QPainter( self )
p.drawPixmap(QtCore.QPoint(l, self.renderer.height-t), pixmap)
p.end()
self.replot = False
self.drawRect = False
示例9: __init__
def __init__(self, figure):
QtGui.QWidget.__init__(self)
FigureCanvasAgg.__init__(self, figure)
self.figure = figure
self.setMouseTracking(True)
w,h = self.get_width_height()
self.resize( w, h )
self.drawRect = False
self.rect = []
self.replot = True
self.pixmap = QtGui.QPixmap()
示例10: _render_figure
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(0,0)
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'
示例11: paintEvent
def paintEvent(self, e):
"""
Draw to the Agg backend and then copy the image to the qt.drawable.
In Qt, all drawing should be done inside of here when a widget is
shown onscreen.
"""
p = QtGui.QPainter( self )
# only replot data when needed
if type(self.replot) is bool: # might be a bbox for blitting
if (self.replot ):
#stringBuffer = str( self.buffer_rgba(0,0) )
FigureCanvasAgg.draw( self )
# matplotlib is in rgba byte order.
# qImage wants to put the bytes into argb format and
# is in a 4 byte unsigned int. little endian system is LSB first
# and expects the bytes in reverse order (bgra).
if ( QtCore.QSysInfo.ByteOrder == QtCore.QSysInfo.LittleEndian ):
stringBuffer = self.renderer._renderer.tostring_bgra()
else:
stringBuffer = self.renderer._renderer.tostring_argb()
qImage = QtGui.QImage(stringBuffer, self.renderer.width,
self.renderer.height,
QtGui.QImage.Format_ARGB32)
self.pixmap = self.pixmap.fromImage(qImage)
p.drawPixmap(QtCore.QPoint(0, 0), self.pixmap)
# draw the zoom rectangle to the QPainter
if (self.drawRect):
p.setPen(QtGui.QPen(Qt.black, 1, Qt.DotLine))
p.drawRect(self.rect[0], self.rect[1], self.rect[2], self.rect[3])
# we are blitting here
else:
bbox = self.replot
w, h = int(bbox.width), int(bbox.height)
l, t = bbox.ll().x().get(), bbox.ur().y().get()
reg = self.copy_from_bbox(bbox)
stringBuffer = reg.to_string()
qImage = QtGui.QImage(stringBuffer, w, h, QtGui.QImage.Format_ARGB32)
self.pixmap = self.pixmap.fromImage(qImage)
p.drawPixmap(QtCore.QPoint(l, self.renderer.height-t), self.pixmap)
p.end()
self.replot = False
self.drawRect = False
示例12: keyPressEvent
def keyPressEvent(self, event):
key = self._get_key(event)
FigureCanvasAgg.key_press_event(self, key)
示例13: mousePressEvent
def mousePressEvent(self, event):
x = event.pos().x()
# flipy so y=0 is bottom of canvas
y = self.figure.bbox.height - event.pos().y()
button = self.buttond[event.button()]
FigureCanvasAgg.button_press_event( self, x, y, button )
示例14: mouseMoveEvent
def mouseMoveEvent(self, event):
x = event.x()
# flipy so y=0 is bottom of canvas
y = self.figure.bbox.height - event.y()
FigureCanvasAgg.motion_notify_event( self, x, y )
示例15: keyReleaseEvent
def keyReleaseEvent(self, event):
key = self._get_key(event)
FigureCanvasAgg.key_release_event(self, key)