本文整理汇总了Python中matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg类的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasQTAgg类的具体用法?Python FigureCanvasQTAgg怎么用?Python FigureCanvasQTAgg使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FigureCanvasQTAgg类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: keyPressEvent
def keyPressEvent(self, event):
if self.redetecter:
self.detecter()
key = event.key()
txt = event.text()
modifiers = event.modifiers()
accept = True
debug(u"key: ", key)
if key == Qt.Key_Delete and self.select:
if shift_down(event):
self.executer(u"%s.cacher()" %self.select.nom)
else:
self.executer(u"%s.supprimer()" %self.select.nom)
elif key in (Qt.Key_Return, Qt.Key_Enter) and self.editeur.objet is not self.select:
self.editer(shift_down(event))
elif self.editeur and not self.editeur.key(key, txt, modifiers):
accept = False
if key == Qt.Key_Escape and self.interaction:
print "ESCAPE !"
self.interaction(special="ESC")
accept = True
if not accept:
FigureCanvasQTAgg.keyPressEvent(self, event)
开发者ID:TeddyBoomer,项目名称:geophar,代码行数:26,代码来源:wxcanvas.py
示例2: RewardWidget
class RewardWidget(QtGui.QWidget):
def __init__(self, parent=None):
super(RewardWidget, self).__init__(parent)
self.samples = 0
self.resize(1500, 100)
self.figure = Figure()
self.canvas = FigureCanvasQTAgg(self.figure)
self.axes = self.figure.add_axes([0, 0, 1, 1])
self.layoutVertical = QtGui.QVBoxLayout(self)
self.layoutVertical.addWidget(self.canvas)
def set_time_range(self, time_range):
self.time_range = time_range
range_length = int((time_range[1] - time_range[0]))
self.rewards = [0] * (range_length * 100)
def add_data(self, data_range, data):
begin = int(round((data_range[0] - self.time_range[0]) * 100))
end = int(round((data_range[1] - self.time_range[0]) * 100)) + 1
self.rewards[begin:end] = [data for x in range(end-begin)]
range_length = int((self.time_range[1] - self.time_range[0]))
self.axes.clear()
self.axes.set_xlim([0,range_length*100])
self.axes.set_ylim([-10.0,10.0])
self.axes.plot(self.rewards)
self.canvas.draw()
#print(self.rewards)
开发者ID:OSUrobotics,项目名称:rqt_common_plugins,代码行数:34,代码来源:reward_widget.py
示例3: __init__
def __init__(self, parent=None, width=5, height=4, dpi=100):
self.fig = Figure(figsize=(width, height), dpi=dpi)
FigureCanvasQTAgg.__init__(self, self.fig)
self.setParent(parent)
FigureCanvas.setSizePolicy(self, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
FigureCanvas.updateGeometry(self)
开发者ID:cta-observatory,项目名称:dragonboard_testbench,代码行数:7,代码来源:plotting.py
示例4: MatplotlibWidget
class MatplotlibWidget(QtGui.QWidget):
"""
Implements a Matplotlib figure inside a QWidget.
Use getFigure() and redraw() to interact with matplotlib.
Example::
mw = MatplotlibWidget()
subplot = mw.getFigure().add_subplot(111)
subplot.plot(x,y)
mw.draw()
"""
def __init__(self, size=(5.0, 4.0), dpi=100):
QtGui.QWidget.__init__(self)
self.fig = Figure(size, dpi=dpi)
self.canvas = FigureCanvas(self.fig)
self.canvas.setParent(self)
self.toolbar = NavigationToolbar(self.canvas, self)
self.vbox = QtGui.QVBoxLayout()
self.vbox.addWidget(self.toolbar)
self.vbox.addWidget(self.canvas)
self.setLayout(self.vbox)
def getFigure(self):
return self.fig
def draw(self):
self.canvas.draw()
开发者ID:altexdim,项目名称:pysimiam-original-fork,代码行数:31,代码来源:MatplotlibWidget.py
示例5: __init__
def __init__(self, parent=None, width=5, height=4, dpi=72):
# fiugrueの生成
self.fig = Figure(figsize=(width, height), dpi=dpi,
facecolor=[0.5, 0.5, 0.5], edgecolor=None,
linewidth=1.0,
frameon=True, tight_layout=True)
# axesハンドルの生成
self.axes = self.fig.add_subplot(111)
# 再描画では上書きしない
self.axes.hold(False)
# 画像の初期表示
self.compute_initial_fiugre()
# コンストラクタ
FigureCanvas.__init__(self, self.fig)
# 親のウィジェットを生成
self.setParent(parent)
# サイズの設定
# FigureCanvas.setSizePolicy(self,
# QtGui.QSizePolicy.Expanding,
# QtGui.QSizePolicy.Expanding)
# サイズの更新
FigureCanvas.updateGeometry(self)
开发者ID:peace098beat,项目名称:SignalProcessingApp,代码行数:28,代码来源:MplCanvas.py
示例6: __init__
def __init__(self, spurset, fef, parent):
chart.__init__(self, spurset, fef, parent)
# make the figure blend in with the native application look
bgcol = parent.palette().window().color().toRgb()
bgcol = [bgcol.redF(), bgcol.greenF(), bgcol.blueF()]
self.fig = Figure()
self.fig.set_facecolor(bgcol)
# a FigureCanvas can be added as a QWidget, so we use that
self.plot = FigureCanvas(self.fig)
self.plot.setParent(parent)
self.ax = self.fig.add_subplot(111)
# TODO skip this, just do a redraw() after initialization?
self.ax.set_xlim(self.spurset.RFmin, self.spurset.RFmax)
self.ax.set_ylim(-0.5*self.spurset.dspan, 0.5*self.spurset.dspan)
self.ax.grid(True)
self.fig.tight_layout()
# a second figure to hold the legend
self.legendFig = Figure()
self.legendFig.set_facecolor(bgcol)
self.legendCanvas = FigureCanvas(self.legendFig)
self.legendFig.legend(*self.ax.get_legend_handles_labels(),
loc='upper left')
# connect up the picker watching
self.picked_obj = None
self._pick = self.plot.mpl_connect('pick_event', self.onpick)
self._drag = self.plot.mpl_connect('motion_notify_event', self.ondrag)
self._drop = self.plot.mpl_connect('button_release_event', self.ondrop)
开发者ID:patrickyeon,项目名称:spurdist,代码行数:33,代码来源:mplchart.py
示例7: __init__
def __init__(self):
"""Constructor"""
# Create the figure in the canvas
self.fig = Figure()
self.ax = self.fig.add_subplot(111)
FigureCanvas.__init__(self, self.fig)
# generates first "empty" plot
t = [0.0]
e = [0.0]
self.line, = self.ax.plot(t,
e,
color="black",
linestyle="-",
linewidth=1.0)
# Set some options
self.T = {{L}} / {{U}}
self.Ek = {{E_KIN}}
self.ax.grid()
self.ax.set_xlim(0, 10.0)
self.ax.set_ylim(0.0, 1.1)
self.ax.set_autoscale_on(False)
self.ax.set_xlabel(r"$t U / L$", fontsize=21)
self.ax.set_ylabel(r"$\mathcal{E}_{k}(t) / \mathcal{E}_{k}(0)$", fontsize=21)
# force the figure redraw
self.fig.canvas.draw()
# call the update method (to speed-up visualization)
self.timerEvent(None)
# start timer, trigger event every 1000 millisecs (=1sec)
self.timer = self.startTimer(1000)
开发者ID:sanguinariojoe,项目名称:aquagpusph,代码行数:29,代码来源:plot_e.py
示例8: TrimCanvas
class TrimCanvas(QtGui.QWidget):
def __init__(self):
super(TrimCanvas, self).__init__()
self.figure = plt.figure()
self.canvas = FigureCanvas(self.figure)
self.toolbar = NavigationToolbar2QT(self.canvas, self)
self.frames = None
self.data = None
self.handles = None
self.timedata = None
self.interval = None
def replot(self, mode):
data = plots.raw(f_sampling, self.data)
self.timedata = data['x_vector']
data['legend'] = 'Tymczasowe nagranie'
if mode == 'm':
data['sliders'] = (self.timedata[-1]*0.1, self.timedata[-1]*0.1 + self.interval, self.interval)
self.handles = plot_trimmable(self.figure, data)
else:
data['tight'] = True
self.handles = plot_function(self.figure, data)
self.canvas.draw()
def clear_data(self):
self.figure.clear()
self.canvas.draw()
self.frames = None
self.data = None
def data2frames(self):
bytes = self.data.tobytes()
self.frames = [bytes[i:i+2048] for i in range(0, len(bytes), 2048)]
开发者ID:pnikrat,项目名称:spyker_inzynierka,代码行数:33,代码来源:recording.py
示例9: histpanel
class histpanel(QtGui.QWidget):
def __init__(self,app):
super(histpanel,self).__init__()
self.layout =QtGui.QVBoxLayout()
self.setLayout(self.layout )
self.figure=plt.figure()
self.canvas=FigureCanvas(self.figure)
self.layout.addWidget(self.canvas)
self.histdata=[]
self.app=app
def plot(self,datastr):
data=json.loads(unicode(datastr))
if "history" in data["data"]:
self.histdata=np.array(data["data"]["history"])
self.timestep(datastr)
def timestep(self,resultstr):
data=json.loads(unicode(resultstr))
timestamp=data["data"]["stat"]["time"]
if ( self.app.tab.currentIndex()==2 ):
self.figure.clf()
ax=self.figure.add_subplot(111)
self.figure.set_frameon(False)
ax.patch.set_alpha(0)
ax.set_xlabel("Time [s]")
ax.set_ylabel("Image Count")
ppl.hist(ax,self.histdata-np.ceil(timestamp),bins=100,range=(-100,0))
ax.set_xlim((-100,0))
tstr= datetime.datetime.fromtimestamp(timestamp).strftime('%Y-%m-%d %H:%M:%S')
ax.set_title(tstr +", "+ str(data["data"]["stat"]['images processed'])+" Images Processed")
self.canvas.draw()
开发者ID:kjuraic,项目名称:SAXS,代码行数:35,代码来源:histpanel.py
示例10: __init__
def __init__(self, map_, width, height, parent=None, dpi=100, **matplot_args): # pylint: disable=W0613
# self._widthHint = width
# self._heightHint = height
self._origMap = map_
self._map = map_.resample((width, height))
# Old way (segfaults in some environements)
# self.figure = self._map.plot_simple(**matplot_args)
# FigureCanvas.__init__(self, self.figure)
self.figure = Figure()
self._map.plot(figure=self.figure, basic_plot=True, **matplot_args)
self.axes = self.figure.gca()
FigureCanvas.__init__(self, self.figure)
# How can we get the canvas to preserve its aspect ratio when expanding?
# sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred)
# sizePolicy.setHeightForWidth(True)
# self.setSizePolicy(sizePolicy)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
self.setSizePolicy(sizePolicy)
self.setMinimumSize(QtCore.QSize(width, height))
self.setMaximumSize(QtCore.QSize(width, height))
开发者ID:katrienbonte,项目名称:sunpy,代码行数:25,代码来源:rgb_composite.py
示例11: __init__
def __init__(self,parent=None,width=5,height=4,dpi=100):
figure = Figure(figsize=(width,height),dpi=dpi)
FigureCanvas.__init__(self,figure)
self.setParent(parent)
self.axes = figure.add_subplot(111)
self.axes.hold(False)
self.axeX = [0]
开发者ID:CodingDuff,项目名称:MR52_R-n-Game,代码行数:7,代码来源:mrFigureCanvas.py
示例12: MainWidget
class MainWidget(QtGui.QWidget):
def __init__(self, parent=None):
super(MainWidget, self).__init__(parent)
# a figure instance to plot on
self.figure = plt.figure()
# this is the Canvas Widget that displays /embpyqt/python/the `figure`
# it takes the `figure` instance as a parameter to __init__
self.canvas = FigureCanvas(self.figure)
# this is the Navigation widget
# it takes the Canvas widget and a parent
self.toolbar = NavigationToolbar(self.canvas, self)
# Just some button connected to `plot` method
self.button = QtGui.QPushButton('Plot')
self.button.clicked.connect(self.plot)
# set the layout
layout = QtGui.QVBoxLayout()
layout.addWidget(self.toolbar)
layout.addWidget(self.canvas)
layout.addWidget(self.button)
self.setLayout(layout)
def plot(self):
''' plot some random stuff '''
# random data
'''data = [random.random() for i in range(2)]
# create an axis
ax = self.figure.add_subplot(111)
# discards the old graph
ax.hold(False)
# plot data
ax.plot(data, '*-')'''
m = Basemap(projection='robin',lon_0=0,resolution='c')#,latlon=True)
m.bluemarble(scale=0.2)
for friend in rpc.bridge.getFriendList():
print ''
pd = rpc.bridge.getPeerDetails(friend)
print pd['name']
print pd['extAddr']
ld = gi.record_by_addr(pd['extAddr'])
print ld
if ld:
print ld['latitude'],ld['longitude']
x, y = m(ld['longitude'],ld['latitude'])
#m.scatter(x, y,30,marker='o',color='k')
plt.plot(x, y,'ro')
plt.text(x,y,pd['name'],fontsize=9,
ha='center',va='top',color='r',
bbox = dict(boxstyle="square",ec='None',fc=(1,1,1,0.5)))
#plt.text(x,y,pd['name'],fontsize=14,fontweight='bold',
# ha='center',va='center',color='r')
# refresh canvas
self.canvas.draw()
开发者ID:RetroShare,项目名称:WebScriptRS,代码行数:60,代码来源:geoMapIP.py
示例13: Window
class Window(QtGui.QDialog):
def __init__(self, parent=None):
super(Window, self).__init__(parent)
# a figure instance to plot on
self.figure = plt.figure()
self.canvas = FigureCanvas(self.figure)
self.plot()
# set the layout
layout = QtGui.QVBoxLayout()
layout.addWidget(self.canvas)
self.setLayout(layout)
def plot(self):
''' plot some random stuff '''
# random data
data = [random.random() for i in range(10)]
# create an axis
ax = self.figure.add_subplot(111)
# discards the old graph
ax.hold(False)
# plot data
ax.plot(data, '*-')
# refresh canvas
self.canvas.draw()
开发者ID:mattling9,项目名称:COMP4Coursework,代码行数:31,代码来源:Graph+in+py+qt+test.py
示例14: __init__
def __init__(self, parent):
self.parent = parent
self.fig = Figure()
self.ax = self.fig.add_subplot(111)
FigureCanvas.__init__(self, self.fig)
#self.cidPress = self.mpl_connect('button_press_event', self.onClick)
#self.cidRelease = self.mpl_connect('button_release_event', self.onRelease)
#self.X = np.random.rand(5,5)
#rows,cols,self.slices = self.X.shape
#self.Y = np.random.rand(5,5)
#rows,cols,self.slices = self.X.shape
newdata = np.ones(2*2)
newarray = np.reshape(newdata, (2, 2))
self.data = newarray
#self.im = self.ax.matshow(self.X[:,:])
#self.im = self.ax.matshow(self.data)
self.update()
self.fig.canvas.draw()
self.cnt = 0
self.setupSelector()
开发者ID:HaeffnerLab,项目名称:sqip,代码行数:29,代码来源:AndorClient.py
示例15: PlotWidget
class PlotWidget(QWidget):
"""
matplotlib plot widget
"""
def __init__(self,parent):
super(PlotWidget,self).__init__(parent)
self.figure = plt.figure()
self.canvas = FigureCanvas(self.figure)
self.toolbar = NavigationToolbar(self.canvas, self)
self.ax = self.figure.add_subplot(111) # create an axis
layout = QVBoxLayout()
layout.addWidget(self.toolbar)
layout.addWidget(self.canvas)
self.setLayout(layout)
def clear(self):
self.ax.cla()
def test(self):
""" plot random data """
df = fakeData()
#self.ax.hold(False) # discard old data
#self.ax.plot(df,'o-')
self.clear()
df.plot(ax=self.ax)
self.canvas.draw()
开发者ID:yangjie5585,项目名称:spreadBuilder,代码行数:32,代码来源:widgets.py
示例16: __init__
def __init__(self, parent=None,
size = (7,3.5),
dpi = 100,
logx = False,
logy = False,
legends = True,
bw = False):
self.fig = Figure(figsize=size, dpi=dpi) #in inches
FigureCanvas.__init__(self, self.fig)
FigureCanvas.setSizePolicy(self,
qt.QSizePolicy.Expanding,
qt.QSizePolicy.Expanding)
self.curveTable = None
self.dpi=dpi
ddict = {'logx':logx,
'logy': logy,
'legends':legends,
'bw':bw}
self.ax=None
self.curveList = []
self.curveDict = {}
self.setParameters(ddict)
#self.setBlackAndWhiteEnabled(bw)
#self.setLogXEnabled(logx)
#self.setLogYEnabled(logy)
#self.setLegendsEnabled(legends)
self.xmin = None
self.xmax = None
self.ymin = None
self.ymax = None
self.limitsSet = False
开发者ID:marcus-oscarsson,项目名称:pymca,代码行数:33,代码来源:QPyMcaMatplotlibSave1D.py
示例17: Widget
class Widget(QWidget):
def __init__(self, parent=None):
QWidget.__init__(self, parent)
QVBoxLayout(self)
self.figure = Figure()
self.canvas = FigureCanvas(self.figure)
self.canvas.setParent(self)
codes, verts = zip(*pathdata)
path = mpath.Path(verts, codes)
patch = mpatches.PathPatch(path, facecolor="red", edgecolor="yellow", alpha=0.5)
self.axes = self.figure.add_subplot(111)
self.axes.add_patch(patch)
x, y = zip(*path.vertices)
self.axes.plot(x, y, "go-")
self.axes.grid()
self.axes.set_xlim(-3, 4)
self.axes.set_ylim(-3, 4)
self.axes.set_title("spline paths")
self.layout().addWidget(self.canvas)
self.canvas.draw()
开发者ID:hftsai,项目名称:gulon-soft,代码行数:28,代码来源:mpl_path_qt.py
示例18: __init__
def __init__(self, filename):
FigureCanvas.__init__(self, Figure())
self.spike_axes = self.figure.add_subplot(131)
self.spike_axes.set_title('Spike trains')
self.vm_axes = self.figure.add_subplot(132)
self.vm_axes.set_title('Vm')
self.ca_axes = self.figure.add_subplot(133)
self.ca_axes.set_title('[Ca2+]')
self.spike_axes_bg = self.copy_from_bbox(self.spike_axes.bbox)
self.vm_axes_bg = self.copy_from_bbox(self.vm_axes.bbox)
self.ca_axes_bg = self.copy_from_bbox(self.ca_axes.bbox)
self.datafilename = filename
self.spiketrain_dict = {}
self.vm_dict = {}
self.ca_dict = {}
self.spike_matrix = None
self.simtime = None
self.simdt = None
self.plotdt = None
self.timestamp = None
self.frame_count = 0
self.timepoints = []
self.cell_index_map = {}
self.index_cell_map = {}
self._read_data()
self.draw()
开发者ID:BhallaLab,项目名称:thalamocortical,代码行数:26,代码来源:dataviz_20101220.py
示例19: paintEvent
def paintEvent(self, event):
Canvas.paintEvent(self, event)
if not self.limit_mode:
return
# convert to data units
height = self.figure.bbox.height
t = lambda s: np.array(self.axes.transData.transform(s))
qp = QPainter()
qp.begin(self)
qp.setPen(QColor(*self.limit_color))
# Draw polygon
if self.limit_mode and self.limit_type == 1:
for i in range(len(self.limit_data) - 1):
start = t(self.limit_data[i])
end = t(self.limit_data[i + 1])
qp.drawLine(start[0], height - start[1],
end[0], height - end[1])
if self.limit_data:
start = t(self.limit_data[-1])
end = t((self._mouse_move_event.xdata,
self._mouse_move_event.ydata))
qp.drawLine(start[0], height - start[1],
end[0], height - end[1])
# Draw an ellipse
if self.limit_mode and self.limit_type == 2 and self.limit_data:
# convert to display coordinates
startp = t(self.limit_data[0])
mouse = t((self._mouse_move_event.xdata,
self._mouse_move_event.ydata))
center = 0.5 * (startp + mouse)
if len(self.limit_data) == 1: # we've set the center, draw line
eheight = 30
angvec = mouse - center
angle = np.arctan2(angvec[1], angvec[0])
ewidth = np.linalg.norm(angvec)
elif len(self.limit_data) > 1: # we've also fixed the angle
angleline = t(self.limit_data[1])
center = 0.5 * (startp + angleline)
angvec = angleline - center
angle = np.arctan2(angvec[1], angvec[0])
ewidth = np.linalg.norm(angvec)
angvec = angvec / ewidth
mvec = mouse - center
eheight = np.linalg.norm(mvec - np.dot(mvec, angvec) * angvec)
if self.limit_data:
qp.translate(center[0], height - center[1])
qp.rotate(-angle * 180.0 / np.pi)
qp.drawEllipse(QPoint(0, 0), ewidth, eheight)
qp.drawLine(-ewidth, 0, ewidth, 0)
qp.drawLine(0, -eheight, 0, eheight)
qp.end()
开发者ID:bwillers,项目名称:pyclust,代码行数:60,代码来源:featurewidget.py
示例20: WireMap
class WireMap(QtGui.QWidget):
def __init__(self, parent=None):
super(WireMap,self).__init__(parent)
self.parent = parent
self.setup_widgets()
self.vbox = QtGui.QVBoxLayout(self)
self.vbox.addWidget(self.canvas)
self.vbox.addWidget(self.toolbar)
def setup_widgets(self):
# setting up dimensions
self.fig = Figure((5.0, 4.0), dpi=100)
#attaching the figure to the canvas
self.canvas = FigureCanvas(self.fig)
#attaching a toolbar to the canvas
self.toolbar = NavigationToolbar(self.canvas, self.parent)
self.axs = [[] for i in range(6)]
self.pts = [[None]*6 for i in range(6)]
sector_grid = gridspec.GridSpec(2,3,wspace=0.3,hspace=0.2)
for sec in range(6):
slyr_grid = gridspec.GridSpecFromSubplotSpec(6,1,
wspace=0.0,hspace=0.1,
subplot_spec=sector_grid[sec])
for slyr in range(6):
self.axs[sec].append(
self.fig.add_subplot(slyr_grid[5-slyr]))
def update_plots(self):
for sec in range(6):
for slyr in range(6):
self.pts[sec][slyr] = \
self.superlayer_plot(self.axs[sec][slyr],sec,slyr)
self.canvas.draw()
def superlayer_plot(self,ax,sec,slyr):
if not hasattr(self,'data'):
self.data = fetchCrateArray(session)
pt = ax.imshow(self.data[sec][slyr],
origin='lower',
aspect='auto',
interpolation='nearest',
extent=[0.5,112.5,-0.5,5.5],
vmin=0,
cmap=cm.ocean)
if slyr == 5:
ax.set_title('Sector '+str(sec+1))
if (sec > 2) and (slyr == 0):
ax.xaxis.set_ticks([1]+list(range(32,113,32)))
ax.xaxis.set_ticklabels([1]+list(range(32,113,32)))
else:
ax.xaxis.set_major_locator(pyplot.NullLocator())
ax.set_ylabel(str(slyr+1))
ax.yaxis.set_major_locator(pyplot.NullLocator())
ax.hold(False)
return pt
开发者ID:theodoregoetz,项目名称:clas12-dc-wiremap,代码行数:60,代码来源:wire_signal_cable_status.py
注:本文中的matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论