本文整理汇总了Python中matplotlib.figure.Figure.draw方法的典型用法代码示例。如果您正苦于以下问题:Python Figure.draw方法的具体用法?Python Figure.draw怎么用?Python Figure.draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.figure.Figure
的用法示例。
在下文中一共展示了Figure.draw方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MatplotlibWidget
# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import draw [as 别名]
class MatplotlibWidget(FigureCanvas):
def __init__(self, parent=None):
super(MatplotlibWidget, self).__init__(Figure())
#self.hide()
self.setParent(parent)
self.figure = Figure()
self.canvas = FigureCanvas(self.figure)
self.ax = self.figure.add_subplot(111)
self.ax.yaxis.grid(color='gray', linestyle='dashed')
def add_plot_line(self, x, y):
self.ax.plot(x, y, 'r')
def add_legend(self, list):
#list of strings like "X1 = blaghlbah"
self.figure.legend([x for x in list], loc='upper left')
def draw_graph(self):
self.figure.draw()
def show_graph(self):
self.figure.show()
def plot_bar_graph(self):
pass
示例2: draw
# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import draw [as 别名]
def draw(self, event):
if self.editAxes:
self.graph.userCustom()
self.graph.colorStyle()
self.formatDate()
self.subplots_adjust(hspace=0.05)
self.graph.hideExtraLines()
self.setLineData()
Figure.draw(self, event)
self.graph.bck = self.saveBackground()
self.graph.showExtraLines()
示例3: print_result
# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import draw [as 别名]
def print_result(self, print_context, render=True):
figure = Figure(facecolor='white', figsize=(6,4.5))
figure.set_dpi(72)
# Don't draw the frame, please.
figure.set_frameon(False)
canvas = _PlotResultCanvas(figure)
axes = figure.add_subplot(111)
self._replay(axes)
width, height = figure.bbox.width, figure.bbox.height
if render:
cr = print_context.get_cairo_context()
renderer = RendererCairo(figure.dpi)
renderer.set_width_height(width, height)
if hasattr(renderer, 'gc'):
# matplotlib-0.99 and newer
renderer.gc.ctx = cr
else:
# matplotlib-0.98
# RendererCairo.new_gc() does a restore to get the context back
# to its original state after changes
cr.save()
renderer.ctx = cr
figure.draw(renderer)
if not hasattr(renderer, 'gc'):
# matplotlib-0.98
# Reverse the save() we did before drawing
cr.restore()
return height
示例4: draw
# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import draw [as 别名]
def draw(self, canvas):
""" Draw the Figure
Wrapper to parent class function. Set also the key_press_event callback
Parameter
---------
canvas: Canvas
Canvas to use to draw the figure
Returns
-------
tmp: Value returned by parent class function call
"""
tmp = MplFig.draw(self, canvas)
if not self._kid:
self._kid = self.canvas.mpl_connect('key_press_event', self._key)
return tmp
示例5: PlotWidget
# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import draw [as 别名]
class PlotWidget(custom_result.ResultWidget):
__gsignals__ = {
'button-press-event': 'override',
'button-release-event': 'override',
'expose-event': 'override',
'size-allocate': 'override',
'unrealize': 'override'
}
def __init__(self, result):
custom_result.ResultWidget.__init__(self)
figsize=(DEFAULT_FIGURE_WIDTH, DEFAULT_FIGURE_HEIGHT)
self.figure = Figure(facecolor='white', figsize=figsize)
self.canvas = _PlotResultCanvas(self.figure)
self.axes = self.figure.add_subplot(111)
self.add_events(gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE)
self.cached_contents = None
self.sidebar_width = -1
def do_expose_event(self, event):
cr = self.window.cairo_create()
if not self.cached_contents:
self.cached_contents = cr.get_target().create_similar(cairo.CONTENT_COLOR,
self.allocation.width, self.allocation.height)
renderer = RendererCairo(self.figure.dpi)
renderer.set_width_height(self.allocation.width, self.allocation.height)
renderer.set_ctx_from_surface(self.cached_contents)
self.figure.draw(renderer)
# event.region is not bound: http://bugzilla.gnome.org/show_bug.cgi?id=487158
# gdk_context = gtk.gdk.CairoContext(renderer.ctx)
# gdk_context.region(event.region)
# gdk_context.clip()
cr.set_source_surface(self.cached_contents, 0, 0)
cr.paint()
def do_size_allocate(self, allocation):
if allocation.width != self.allocation.width or allocation.height != self.allocation.height:
self.cached_contents = None
gtk.DrawingArea.do_size_allocate(self, allocation)
def do_unrealize(self):
gtk.DrawingArea.do_unrealize(self)
self.cached_contents = None
def do_button_press_event(self, event):
if event.button == 3:
custom_result.show_menu(self, event, save_callback=self.__save)
return True
else:
return True
def do_button_release_event(self, event):
return True
def do_realize(self):
gtk.DrawingArea.do_realize(self)
cursor = gtk.gdk.Cursor(gtk.gdk.LEFT_PTR)
self.window.set_cursor(cursor)
def do_size_request(self, requisition):
try:
# matplotlib < 0.98
requisition.width = self.figure.bbox.width()
requisition.height = self.figure.bbox.height()
except TypeError:
# matplotlib >= 0.98
requisition.width = self.figure.bbox.width
requisition.height = self.figure.bbox.height
def recompute_figure_size(self):
width = (self.sidebar_width / self.figure.dpi)
height = width / DEFAULT_ASPECT_RATIO
self.figure.set_figwidth(width)
self.figure.set_figheight(height)
self.queue_resize()
def sync_dpi(self, dpi):
self.figure.set_dpi(dpi)
if self.sidebar_width >= 0:
self.recompute_figure_size()
def set_sidebar_width(self, width):
if self.sidebar_width == width:
return
#.........这里部分代码省略.........
示例6: saveBackground
# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import draw [as 别名]
def saveBackground(self, event):
self.subplots_adjust(left=0.1, right=0.90, bottom=0.15, top=0.92, wspace=0.4, hspace=0.05)
self.setDateFormat()
self.parent.updateStyle()
Figure.draw(self, event)
self.parent.background = self.canvas.copy_from_bbox(self.parent.ax.bbox)