本文整理汇总了Python中matplotlib.backends.backend_wxagg.FigureCanvasWxAgg类的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasWxAgg类的具体用法?Python FigureCanvasWxAgg怎么用?Python FigureCanvasWxAgg使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FigureCanvasWxAgg类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: panAll
def panAll(self, x, y, axesList):
"""
Pans across multiple subplots simultaneously. Use this
function rather than pan to avoid lag on the x-axis.
"""
if not self.enabled: return
i=0
movex, movey = 0, 0
xmin, xmax = 0, 0
for axes in axesList:
if not is_log_x(axes):
xtick = axes.get_xaxis()._get_tick(major=False)._size
movex = (self.getX() - x) / xtick / 10
# TBF: matplotlib's Axes' panx method is broken, so we do it here
axes.xaxis.pan(movex)
if i==0: # we want to keep all plots on a common x-axis
xmin, xmax = axes.viewLim.intervalx().get_bounds()
axes.set_xlim(xmin, xmax)
axes._send_xlim_event()
if not is_log_y(axes):
ytick = axes.get_yaxis()._get_tick(major=False)._size
movey = (self.getY() - y) / ytick / 10
axes.pany(movey)
i += 1
self.panx += movex
self.pany += movey
self.setX(x)
self.setY(y)
FigureCanvasWxAgg.draw(self.getView())
开发者ID:nrao,项目名称:deap,代码行数:32,代码来源:PlotView.py
示例2: rightButtonUp
def rightButtonUp(self, evt, x, y):
"""
Completely overrides base class functionality.
"""
view = self.getView()
if self.selectedAxes is None:
axes, xdata, ydata = self.find_axes(view, x, y)
else:
axes = self.selectedAxes
xdata, ydata = get_data(axes, x, y)
self.setActiveSubplot(axes)
if self.zoomEnabled and self.rightClickUnzoom:
xmin = xmax = None
for axes in self.find_all_axes(view, x, y): # unzoom all axes
self.limits.restore(axes)
if not self.limits.can_unzoom(axes):
# rescale manually - wxmpl will try to autoscale
if xmin is None or xmax is None: # make sure x-axis matches
xmin, xmax = axes.viewLim.intervalx().get_bounds()
axes.set_xlim(xmin, xmax)
axes._send_xlim_event()
view.crosshairs.clear()
view.draw()
view.crosshairs.set(x, y)
if self.IsInfoMode() and axes is not None:
self.DisplayAllSubplots()
FigureCanvasWxAgg.draw(view)
if self.IsPanMode() and axes is not None:
self.panTool.end_pan_all(x, y, self.find_all_axes(view, x, y))
开发者ID:nrao,项目名称:deap,代码行数:34,代码来源:PlotView.py
示例3: __init__
def __init__(self, parent, *args, **kwargs):
"""wx.Panel with a matplotlib figure
Parameters
----------
figsize : tuple
Figure dimensions (width, height) in inches
dpi : int
Dots per inch.
facecolor : mpl color
The figure patch facecolor; defaults to rc ``figure.facecolor``
edgecolor : mpl color
The figure patch edge color; defaults to rc ``figure.edgecolor``
linewidth : scalar
The figure patch edge linewidth; the default linewidth of the frame
frameon : bool
If ``False``, suppress drawing the figure frame
subplotpars :
A :class:`SubplotParams` instance, defaults to rc
tight_layout : bool | dict
If ``False`` use ``subplotpars``; if ``True`` adjust subplot
parameters using :meth:`tight_layout` with default padding.
When providing a dict containing the keys `pad`, `w_pad`, `h_pad`
and `rect`, the default :meth:`tight_layout` paddings will be
overridden. Defaults to rc ``figure.autolayout``.
"""
self.figure = Figure(*args, **kwargs)
FigureCanvasWxAgg.__init__(self, parent, wx.ID_ANY, self.figure)
self.Bind(wx.EVT_ENTER_WINDOW, self.ChangeCursor)
开发者ID:awjamison,项目名称:Eelbrain,代码行数:29,代码来源:mpl_canvas.py
示例4: PageThree
class PageThree(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
self.figure = Figure(dpi=50)
self.canvas = FigureCanvasWxAgg(self, -1, self.figure)
self.toolbar = NavigationToolbar2Wx(self.canvas)
self.toolbar.Realize()
self.plotLast = wx.Button(self,-1,label="Plot Last")
self.Bind(wx.EVT_BUTTON, self.plotLastButtonClick, self.plotLast)
topSizer = wx.BoxSizer(wx.HORIZONTAL)
sizer = wx.BoxSizer(wx.VERTICAL)
topSizer.Add(self.plotLast, 0, wxFIXED_MINSIZE)
topSizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
sizer.Add(topSizer,1,wx.GROW)
sizer.Add(self.toolbar, 0, wx.GROW)
self.SetSizer(sizer)
self.Fit()
def plotLastButtonClick(self, evt):
gh.plotGraph(self.figure)
self.canvas.draw()
开发者ID:michaelcoe,项目名称:robotGUI,代码行数:25,代码来源:RobotGUI.py
示例5: rightButtonUp
def rightButtonUp(self, evt, x, y):
"""
Completely overrides base class functionality.
"""
view = self.getView()
if self.selectedAxes is None:
axes, xdata, ydata = wxmpl.find_axes(view, x, y)
else:
axes = self.selectedAxes
xdata, ydata = get_data(axes, x, y)
self.setActiveSubplot(axes)
if (axes is not None and self.zoomEnabled and self.rightClickUnzoom
and self.limits.restore(axes)):
view.crosshairs.clear()
view.draw()
view.crosshairs.set(x, y)
if self.IsInfoMode() and axes is not None:
self.DisplayAllSubplots()
FigureCanvasWxAgg.draw(view)
if self.IsPanMode() and axes is not None:
self.panTool.end_pan(x, y, axes)
开发者ID:emcnany,项目名称:deap,代码行数:26,代码来源:PlotView.py
示例6: pan
def pan(self, x, y, axes):
"""
Modifies the desired axes limits to make it appear to the user that the
axes are panning as he/she moves the mouse.
"""
if not self.enabled: return
if not is_log_x(axes):
xtick = axes.get_xaxis()._get_tick(major=False)._size
movex = (self.getX() - x) / xtick / 10
# TBF: matplotlib's Axes' panx method is broken, so we do it here
# in the next two lines for them.
axes.xaxis.pan(movex)
axes._send_xlim_event()
self.panx += movex
if not is_log_y(axes):
ytick = axes.get_yaxis()._get_tick(major=False)._size
movey = (self.getY() - y) / ytick / 10
axes.pany(movey)
self.pany += movey
self.setX(x)
self.setY(y)
FigureCanvasWxAgg.draw(self.getView())
开发者ID:nrao,项目名称:deap,代码行数:25,代码来源:PlotView.py
示例7: end_pan_all
def end_pan_all(self, x, y, axesList):
"""
End panning for multiple subplots. Use this function
to correctly reset limits for all axes.
"""
if not self.enabled: return
i = 0
xmin, xmax = 0, 0
for axes in axesList:
if not is_log_x(axes):
# TBF: matplotlib's Axes' panx method is broken, so we do it
# here for them.
axes.xaxis.pan(-self.panx)
if i==0: # we want to keep all plots on a common x-axis
xmin, xmax = axes.viewLim.intervalx().get_bounds()
axes.set_xlim(xmin, xmax)
axes._send_xlim_event()
if not is_log_y(axes):
axes.pany(-self.pany)
axes._send_ylim_event()
i += 1
self.panx = 0
self.pany = 0
FigureCanvasWxAgg.draw(self.getView())
开发者ID:nrao,项目名称:deap,代码行数:29,代码来源:PlotView.py
示例8: ChartCanvas
class ChartCanvas():
"""
Container for the matplotlib (or any other) chart object
"""
def __init__(self, container, config):
# Create the matplotlib figure and attach it to a canvas
self.figure = Figure(
(config.chart_width, config.chart_height),
dpi=config.chart_dpi)
self.canvas = FigureCanvasWxAgg(container, -1, self.figure)
self.chart = self.figure.add_subplot(111)
def layout(self):
return self.canvas
def draw(self, data, _):
"""
Redraw figure
"""
logging.debug('Redrawing time series')
self.chart.clear()
# self.axes.grid(self.cb_grid.IsChecked())
self.chart.plot(data['dates'], data['values'])
self.figure.autofmt_xdate()
self.canvas.draw()
开发者ID:lhoghu,项目名称:python-tools,代码行数:27,代码来源:gui.py
示例9: PlotPanel
class PlotPanel( wx.Panel ):
def __init__(self, parent, dpi = None, color=None, *args, **kwargs):
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg
wx.Panel.__init__(self, parent, wx.ID_ANY, *args, **kwargs)
self.parent = parent
self.figure = mpl.figure.Figure( None, dpi )
self.canvas = FigureCanvasWxAgg(self, -1, self.figure)
self._resizeflag = False
self._SetSize()
self.Bind(wx.EVT_IDLE, self._onIdle)
self.Bind(wx.EVT_SIZE, self._SetSize)
def _SetSize(self, event=None):
pixels = self.GetSize()
self.SetSize(pixels)
self.canvas.SetSize(pixels)
self.figure.set_size_inches( float(pixels[0])/self.figure.get_dpi(),
float(pixels[1])/self.figure.get_dpi() )
def _onIdle(self,event):
self.canvas.draw()
if self._resizeflag:
self._SetSize()
self._resizeflag = False
def draw(self):
pass # To be overriden by children
def make(self):
pass # To be overriden by children
开发者ID:sjt85,项目名称:software,代码行数:32,代码来源:shm_plotter.py
示例10: RealTimePlot
class RealTimePlot(wx.Frame):
def __init__(self,data):
wx.Frame.__init__(self, None, -1, "Real time data plot")
self.redraw_timer = wx.Timer(self)
self.Bind(wx.EVT_TIMER, self.on_redraw_timer, self.redraw_timer)
self.redraw_timer.Start(100)
self.data=data
self.init_plot()
def init_plot(self):
self.data.next()
self.panel = wx.Panel(self)
self.fig = Figure((6.0, 3.0))
self.canvas = FigureCanvasWxAgg(self.panel, -1, self.fig)
self.axes = self.fig.add_subplot(111)
self.plot_data, = self.axes.plot(self.data.get_curr()[0],self.data.get_curr()[1])
self.vbox = wx.BoxSizer(wx.VERTICAL)
self.vbox.Add(self.canvas, 1, flag=wx.LEFT | wx.TOP | wx.GROW)
self.panel.SetSizer(self.vbox)
self.vbox.Fit(self)
def draw_plot(self):
x=self.data.get_curr()[0]
y=self.data.get_curr()[1]
self.plot_data.set_data(x,y)
self.axes.set_xlim((x[0],x[-1]))
self.axes.set_ylim((min(y),max(y)))
self.canvas.draw()
def on_redraw_timer(self,event):
self.data.next()
self.draw_plot()
开发者ID:leo-xiong,项目名称:pyob2read,代码行数:34,代码来源:realtimeplot.py
示例11: WattrGraphPanel
class WattrGraphPanel( WattrGUI.GraphPanel ):
subplot = 0
plots = {}
def __init__(self, parent, fgsize=None, dpi=None):
super(WattrGraphPanel, self).__init__(parent)
self.figure = Figure(fgsize, dpi)
#Transparent figure face color
self.figure.set_facecolor((0,0,0,0,))
self.canvas = FigureCanvasWxAgg(self, -1, self.figure)
# Now put all into a sizer
sizer = self.GetSizer()
# This way of adding to sizer allows resizing
sizer.Add(self.canvas, 1, wx.LEFT|wx.TOP|wx.GROW)
# Best to allow the toolbar to resize!
self.toolbar = NavigationToolbar2Wx(self.canvas)
self.toolbar.Realize()
sizer.Add(self.toolbar, 0, wx.GROW)
self.Fit()
def add_plot(self, x=1, y=1):
self.subplot += 1
plot = self.figure.add_subplot(x, y, self.subplot)
plot.ticklabel_format(axis='y', style='plain', useOffset=False)
plot.ticklabel_format(axis='x', style='plain', useOffset=False)
self.plots[self.subplot] = plot
return plot
def draw(self):
self.canvas.draw()
开发者ID:bxm156,项目名称:EECS398,代码行数:31,代码来源:WattrGraphPanel.py
示例12: Plot
class Plot(wx.Panel):
def __init__(self, parent, dpi=None, **kwargs):
wx.Panel.__init__(self, parent, **kwargs)
self.figure = mpl.figure.Figure(dpi=dpi, figsize=(2, 2))
self.canvas = Canvas(self, wx.ID_ANY, self.figure)
self.check = wx.CheckBox(self, wx.ID_ANY, "Show contour")
self.Bind(wx.EVT_CHECKBOX, self.OnChange, self.check)
self.distMod = SinModulator(self, 'Amplitude modulator', cycles=(2,100), phase=(0, 999))
self.Bind(EVT_UPDATE_EVENT, self.OnChange, self.distMod)
sizerV = wx.BoxSizer(wx.VERTICAL)
sizerV.Add(self.distMod)
sizerV.Add(self.check, 0, wx.EXPAND)
sizerH = wx.BoxSizer(wx.HORIZONTAL)
sizerH.Add(self.canvas, 0, wx.SHAPED | wx.EXPAND)
sizerH.Add(sizerV)
self.SetSizer(sizerH)
self.width, self.height = 256, 256
def CalcPixel(self, i, j):
x = 2.0 * i / self.width - 1.0
y = 2.0 * j / self.height - 1.0
dist = np.sqrt(x**2 + y**2)
angle = np.arctan2(y, x)
data = self.distMod
if data.active:
phase = data.phase * 2.0 * np.pi
newAngle = angle * data.cycles + phase
distDiff = np.cos(newAngle) * dist / data.cycles
else:
distDiff = 0.0
return 1.0 - (dist + distDiff)
def Draw(self):
self.figure.clear()
subplot = self.figure.add_subplot(111)
x = np.arange(0.0, self.width, 1.0)
y = np.arange(0.0, self.height, 1.0)
I, J = np.meshgrid(x, y)
C = np.clip(self.CalcPixel(I, J), 0.0, 1.0)
if self.check.IsChecked():
self.CS = subplot.contour(I, J, C)
subplot.clabel(self.CS, inline=0.1, fontsize=8)
im = subplot.imshow(C, cmap=cm.gray)
im.set_interpolation('bilinear')
def OnChange(self, _):
self.Draw()
self.canvas.draw()
开发者ID:argasek,项目名称:morphine,代码行数:60,代码来源:genlight.py
示例13: CanvasPanel
class CanvasPanel(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
self.figure = Figure(facecolor="black")
self.axes = self.figure.add_axes((0, 0, 1, 1))
self.canvas = FigureCanvas(self, -1, self.figure)
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
self.SetSizer(self.sizer)
self.Fit()
self.axes.set_axis_bgcolor('black')
self.delta = 0
t = arange(0.0, 3.0, 0.01)
s = sin(2 * pi * (t))
self.datatoplot, = self.axes.plot(t, s, 'w', linewidth=3.0)
self.axes.set_ylim((-10,10))
self.axes.grid(True, color="w")
def draw(self):
self.delta = (self.delta + 0.05) % 1
t = arange(0.0, 3.0, 0.01)
s = sin(2 * pi * (t-self.delta))
self.datatoplot.set_ydata(s)
wx.CallLater(10, self.draw)
self.canvas.draw()
self.canvas.Refresh()
开发者ID:Zhang--Ning,项目名称:staBP,代码行数:29,代码来源:plot.py
示例14: _create_canvas
def _create_canvas(self, parent):
panel = QtGui.QWidget()
def mousemoved(event):
if event.xdata is not None:
x, y = event.xdata, event.ydata
name = "Axes"
else:
x, y = event.x, event.y
name = "Figure"
panel.info.setText("%s: %g, %g" % (name, x, y))
panel.mousemoved = mousemoved
vbox = QtGui.QVBoxLayout()
panel.setLayout(vbox)
mpl_control = FigureCanvas(self.value) #❷
vbox.addWidget(mpl_control)
if hasattr(self.value, "canvas_events"):
for event_name, callback in self.value.canvas_events:
mpl_control.mpl_connect(event_name, callback)
mpl_control.mpl_connect("motion_notify_event", mousemoved)
if self.factory.toolbar: #❸
toolbar = Toolbar(mpl_control, panel)
vbox.addWidget(toolbar)
panel.info = QtGui.QLabel(panel)
vbox.addWidget(panel.info)
return panel
开发者ID:Andor-Z,项目名称:scpy2,代码行数:33,代码来源:mpl_figure_editor.py
示例15: __init__
def __init__(self,parent):
self.data_t = [0]
self.data_y = [0]
self.data_y2 = [0]
self.dpi = 100
self.fig = Figure((3.0, 3.0), dpi=self.dpi)
self.axes = self.fig.add_subplot(111)
pylab.setp(self.axes.get_xticklabels(), fontsize=10)
pylab.setp(self.axes.get_yticklabels(), fontsize=10)
# plot the data as a line series, and save the reference
# to the plotted line series
#
self.plot_data = self.axes.plot(
self.data_t,self.data_y,'y',
self.data_t,self.data_y2,'c',
)
ymin = -30
ymax = 30
self.axes.set_ybound(lower=ymin, upper=ymax)
self.axes.set_xlim(0, 20)
self.axes.grid(True)
FigCanvas.__init__(self, parent, -1, self.fig)
self.drawing = False
开发者ID:klvt,项目名称:fiwt,代码行数:28,代码来源:dynamic_chart.py
示例16: EdgesCumulBarGraph
class EdgesCumulBarGraph(wx.Panel):
''' This panel holds edges cumulative bar graph. '''
def __init__(self, parent):
''' parent is a fram instance. '''
wx.Panel.__init__(self, parent = parent, id = -1)
self.figure = Figure(dpi = DPI, figsize = (8, 4))
self.canvas = FigureCanvas(self, -1, self.figure)
self.axes = self.figure.add_subplot(111)
# Labels
self.axes.set_title("Cumulative Number of Major Edges per Interval")
self.axes.set_ylabel("Cumulative number of edges")
self.axes.set_xlabel("Intervals (%)")
# Sizers
bSizer = wx.BoxSizer(wx.HORIZONTAL)
bSizer.Add(self.canvas, 1, wx.EXPAND)
self.SetSizer(bSizer)
def DefineBarGraph(self, left, height):
''' Create bar graph. '''
self.axes.bar(left = left, height = height, width = 5, bottom = 0, color = "b")
def DrawBarGraph(self):
''' Draw the bar graph. '''
self.canvas.draw()
开发者ID:jump3r,项目名称:LSA_APP_linux,代码行数:30,代码来源:GraphTools.py
示例17: CapacityPanel
class CapacityPanel(MyPanel):
def __init__(self, *args, **kwargs):
MyPanel.__init__(self, *args, **kwargs)
self.vbox = wx.BoxSizer(wx.VERTICAL)
fig = Figure(facecolor=self.face_col)
self.ax = fig.add_subplot(111)
self.canvas = FigureCanvas(self, -1, fig)
self.vbox.Add(self.canvas, flag = wx.EXPAND | wx.ALL)
self.SetSizerAndFit(self.vbox)
pub.subscribe(self.redraw, "assignments_calced")
def redraw(self, message):
"""Create a histogram"""
e_caps = self.model.excessCap()
e_caps = [x * 100 for x in e_caps]
self.ax.clear()
n, bins, patches = self.ax.hist(e_caps, normed=False, bins=10, color="cornflowerblue",
rwidth=.8, linewidth=0)
self.ax.set_xlabel("Excess Capacity (%)")
self.ax.set_ylabel("No. of Courses")
self.ax.set_title("Distribution of Excess Capacity")
num_courses = float(len(e_caps))
s_labels = [ 100 * p.get_height()/num_courses for p in patches]
s_labels = [ "%.0f%%" % p for p in s_labels]
self.labelBars(patches, s_labels, self.ax)
self.canvas.draw()
开发者ID:vgupta1,项目名称:ClassE,代码行数:32,代码来源:plotPanels.py
示例18: GraphPanel
class GraphPanel(wx.Panel):
def __init__(self,parent):
wx.Panel.__init__(self,parent)
self.SetBackgroundColour('#FFFFFF')
self.quote = wx.StaticText(self,label = "GRAPH PANEL", pos = (200,10))
self.figure = Figure(dpi=100,figsize=(5,8))
self.axes = self.figure.add_subplot(111)
self.axes.axis([0,1,0,60])
self.axes.set_ylabel('time (s)')
green = self.axes.axhline(y=-1,color='g',lw=4)
blue = self.axes.axhline(y=-1,color='b',lw=4)
red = self.axes.axhline(y=-1,color='r',lw=4)
self.axes.legend((green,blue,red),("Tone","Level Press","Reward"),loc="upper right")
self.canvas = FigureCanvas(self, -1, self.figure)
wx.EVT_PAINT(self, self.OnPaint)
def OnPaint(self, event):
self.canvas.draw()
event.Skip()
def OnSetFocus(self, event):
#self.color = '#0099f7'
self.color = 'yellow'
self.Refresh()
def OnKillFocus(self, event):
self.color = '#b3b3b3'
self.Refresh()
开发者ID:lrajmohan,项目名称:PyView,代码行数:28,代码来源:LeverPress_AWv1.2.py
示例19: BarsFrame
class BarsFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None)
self.data = [5, 6, 9, 14]
self.create_main_panel()
self.draw_figure()
def create_main_panel(self):
self.panel = wx.Panel(self)
self.fig = Figure((5.0, 4.0))
self.canvas = FigCanvas(self.panel, -1, self.fig)
self.axes = self.fig.add_subplot(111)
self.vbox = wx.BoxSizer(wx.VERTICAL)
self.vbox.Add(self.canvas)
self.panel.SetSizer(self.vbox)
self.vbox.Fit(self)
def draw_figure(self):
x = range(len(self.data))
self.axes.clear()
self.axes.bar(left=x, height=self.data)
self.canvas.draw()
def on_exit(self, event):
self.Destroy()
开发者ID:jkhulme,项目名称:french75,代码行数:26,代码来源:wx_mpl.py
示例20: DemoPanel2
class DemoPanel2(wx.Panel):
def __init__(self, *args, **kwds):
# begin wxGlade: DemoPanel2.__init__
kwds["style"] = wx.TAB_TRAVERSAL
wx.Panel.__init__(self, *args, **kwds)
self.__set_properties()
self.__do_layout()
# end wxGlade
self.figure = Figure(figsize=(6,4), dpi=80)
self.axes = self.figure.add_subplot(111)
self.canvas = FigureCanvas(self, wx.ID_ANY, self.figure)
self.axes.set_autoscale_on(False)
self.axes.axis([-20,20,0,0.7])
self.axes.set_title('Histogram')
#self.particles = [None]
#self.axes.hist(self.particles, 25, label = "Histogram") #hist return 3 elements tuple
#self.axes.legend()
self.canvas.draw()
#self.bg = self.canvas.copy_from_bbox(self.axes.bbox)
def __set_properties(self):
# begin wxGlade: DemoPanel2.__set_properties
pass
# end wxGlade
def __do_layout(self):
# begin wxGlade: DemoPanel2.__do_layout
pass
开发者ID:delding,项目名称:dist-pf,代码行数:31,代码来源:Demo_Erli.py
注:本文中的matplotlib.backends.backend_wxagg.FigureCanvasWxAgg类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论