本文整理汇总了Python中matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg.setParent方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasQTAgg.setParent方法的具体用法?Python FigureCanvasQTAgg.setParent怎么用?Python FigureCanvasQTAgg.setParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg
的用法示例。
在下文中一共展示了FigureCanvasQTAgg.setParent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PlotTDistributionDistributionFunction
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setParent [as 别名]
def PlotTDistributionDistributionFunction(df):
if df>0:
main_frame = QtGui.QWidget()
dpi = 100
fig = Figure((5.0, 4.0), dpi=dpi)
canvas = FigureCanvas(fig)
canvas.setParent(main_frame)
axes = fig.add_subplot(111)
mpl_toolbar = NavigationToolbar(canvas, main_frame)
hbox = QtGui.QHBoxLayout()
vbox = QtGui.QVBoxLayout()
vbox.addWidget(canvas)
vbox.addWidget(mpl_toolbar)
vbox.addLayout(hbox)
main_frame.setLayout(vbox)
axes.clear()
alpha = 0.0005 #R'da o sekilde alinmis, burada da ayni olmas? icin bu deger verildi
sequance = stats.t.isf(alpha, df)
x = np.linspace(-sequance, sequance, 100) #100 adet veri default verildi
rv = stats.t(df)
y = rv.cdf(x)
axes.plot(x,y)
canvas.draw()
return main_frame
else:
return False, "Serbestlik derecesi 0'dan kucuk olamaz."
示例2: dibujante2
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setParent [as 别名]
class dibujante2(QMainWindow):
def __init__(self, parent, cont):#Hay que pasarle la ventana que lo invoca
QMainWindow.__init__(self, parent)
self.fm = cont.dominio.metodo
self.fm.calcular()
#self.fm.calcularpozo(1,1,500)
#self.fm.calcularpozo(10,0.2,10)
self.main_frame = QWidget()
self.setWindowTitle(u'Gráficas')
self.canvas = FigureCanvas(self.fm.fig)
self.canvas.setParent(self.main_frame)
vbox = QVBoxLayout()
vbox.addWidget(self.canvas)
self.setCentralWidget(self.main_frame)
self.fm.axt.mouse_init()
def draw(self):
self.canvas.draw()
示例3: display
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setParent [as 别名]
def display(self):
"""
Show the plot in an interactive window.
"""
# Host widget for show():
app = QApplication(sys.argv)
app.aboutToQuit.connect(app.deleteLater)
main_frame = QWidget()
# Attach canvas to host widget:
canvas = FigureCanvasQTAgg(self)
canvas.setParent(main_frame)
# Make navigation toolbar:
mpl_toolbar = NavigationToolbar2QT(self.canvas, main_frame)
# Set up layout:
vbox = QVBoxLayout()
vbox.addWidget(mpl_toolbar)
vbox.addWidget(self.canvas)
# Set the layout to the host widget:
main_frame.setLayout(vbox)
# Set figure manager:
FigureManagerQT(self.canvas, 1)
# Show plot:
self.show()
app.exec_()
示例4: CreateAnovaResult
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setParent [as 别名]
def CreateAnovaResult(x_plot, y_plot, x_fcrit, y_fcrit, F_critical):
main_frame = QtGui.QWidget()
dpi = 100
fig = Figure((5.0, 4.0), dpi=dpi)
canvas = FigureCanvas(fig)
canvas.setParent(main_frame)
axes = fig.add_subplot(111)
mpl_toolbar = NavigationToolbar(canvas, main_frame)
hbox = QtGui.QHBoxLayout()
vbox = QtGui.QVBoxLayout()
vbox.addWidget(canvas)
vbox.addWidget(mpl_toolbar)
vbox.addLayout(hbox)
main_frame.setLayout(vbox)
axes.clear()
# Plot the F-Distribution for dfB and dfW
axes.fill_between(x_plot, y_plot, alpha=.2)
axes.plot(x_plot, y_plot)
# Plot the F-critical value at alpha .05
axes.fill_between(x_fcrit, y_fcrit, alpha=.5)
axes.text(F_critical, .07, '$F_{critical}=$'+str(F_critical))
axes.set_xlabel(u'F-degerleri')
axes.set_ylabel(u'Olasilik')
canvas.draw()
return main_frame
示例5: __init__
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setParent [as 别名]
class MatplotlibPlot:
""" Class encapsulating a matplotlib plot"""
def __init__(self, parent = None, dpi = 100, size = (5,5)):
""" Class initialiser """
self.dpi = dpi
self.figure = Figure(size, dpi = self.dpi)
self.canvas = FigureCanvas(self.figure)
self.canvas.setParent(parent)
# Create the navigation toolbar, tied to the canvas
self.toolbar = NavigationToolbar(self.canvas, parent)
self.canvas.show()
self.toolbar.show()
# Reset the plot landscape
self.figure.clear()
def plotMultiPixel(self, info, data):
""" Generate multi-pixel plot """
# Tabula Rasa
self.figure.clear()
rows = math.ceil(math.sqrt(info['nbeams']))
# Display a subplot per beam (randomly for now)
for i in range(info['nbeams']):
ax = self.figure.add_subplot(rows, rows, i)
ax.plot(data[:,512,i])
def updatePlot(self):
self.canvas.draw()
示例6: CreateLinePlot
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setParent [as 别名]
def CreateLinePlot(x,y):
main_frame = QtGui.QWidget()
dpi = 100
fig = Figure((5.0, 4.0), dpi=dpi)
canvas = FigureCanvas(fig)
canvas.setParent(main_frame)
axes = fig.add_subplot(111)
mpl_toolbar = NavigationToolbar(canvas, main_frame)
hbox = QtGui.QHBoxLayout()
vbox = QtGui.QVBoxLayout()
vbox.addWidget(canvas)
vbox.addWidget(mpl_toolbar)
vbox.addLayout(hbox)
main_frame.setLayout(vbox)
# clear the axes and redraw the plot anew
#
axes.clear()
axes.plot(x, y)
canvas.draw()
return main_frame
示例7: CreateRegression
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setParent [as 别名]
def CreateRegression(x, y):
main_frame = QtGui.QWidget()
dpi = 100
fig = Figure((5.0, 4.0), dpi=dpi)
canvas = FigureCanvas(fig)
canvas.setParent(main_frame)
axes = fig.add_subplot(111)
mpl_toolbar = NavigationToolbar(canvas, main_frame)
hbox = QtGui.QHBoxLayout()
vbox = QtGui.QVBoxLayout()
vbox.addWidget(canvas)
vbox.addWidget(mpl_toolbar)
vbox.addLayout(hbox)
main_frame.setLayout(vbox)
axes.clear()
m, b = np.polyfit(x, y, 1)
yp = polyval([m, b], x)
axes.plot(x, yp)
axes.scatter(x,y)
axes.grid(True)
axes.set_xlabel('x')
axes.set_ylabel('y')
canvas.draw()
return main_frame
示例8: CreatePieChart
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setParent [as 别名]
def CreatePieChart(labels,sizes):
main_frame = QtGui.QWidget()
dpi = 100
fig = Figure((5.0, 4.0), dpi=dpi)
canvas = FigureCanvas(fig)
canvas.setParent(main_frame)
axes = fig.add_subplot(111)
mpl_toolbar = NavigationToolbar(canvas, main_frame)
hbox = QtGui.QHBoxLayout()
vbox = QtGui.QVBoxLayout()
vbox.addWidget(canvas)
vbox.addWidget(mpl_toolbar)
vbox.addLayout(hbox)
main_frame.setLayout(vbox)
# clear the axes and redraw the plot anew
#
axes.clear()
explode=(0, 0, 0, 0)
axes.pie(sizes, labels=labels, autopct='%1.1f%%', shadow=True)
canvas.draw()
return main_frame
示例9: CreateScatter
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setParent [as 别名]
def CreateScatter(valueList1, valueList2):
main_frame = QtGui.QWidget()
dpi = 100
fig = Figure((5.0, 4.0), dpi=dpi)
canvas = FigureCanvas(fig)
canvas.setParent(main_frame)
axes = fig.add_subplot(111)
mpl_toolbar = NavigationToolbar(canvas, main_frame)
hbox = QtGui.QHBoxLayout()
vbox = QtGui.QVBoxLayout()
vbox.addWidget(canvas)
vbox.addWidget(mpl_toolbar)
vbox.addLayout(hbox)
main_frame.setLayout(vbox)
# clear the axes and redraw the plot anew
#
axes.clear()
axes.scatter(valueList1, valueList2, color="blue", edgecolor="none")
canvas.draw()
return main_frame
示例10: __init__
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setParent [as 别名]
def __init__(self, scrollAreaWidgetContents, dataname):
QtGui.QWidget.__init__(self)
self.setParent(scrollAreaWidgetContents)
fig = Figure((3.0, 2.0), dpi=100)
canvas = FigureCanvas(fig)
canvas.setParent(self)
toolbar = myNavigationToolbar(canvas, self)
temporal_toolbar = temporalNavigationToolbar(canvas, self)
axes = fig.add_subplot(111)
axes.autoscale(True)
axes.set_yscale('log')
axes.set_title(dataname)
# place plot components in a layout
plotLayout = QtGui.QVBoxLayout()
plotLayout.addWidget(temporal_toolbar)
plotLayout.addWidget(canvas)
plotLayout.addWidget(toolbar)
self.setLayout(plotLayout)
canvas.setMinimumSize(canvas.size())
self.name = dataname
self.dirList = []
self.dirType = 'Sampled Line'
self.lastPos = -1
self.colors = ['r', 'b', 'k', 'g', 'y', 'c']
self.labels = ['_x','_y','_z']
示例11: CreateHistogram
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setParent [as 别名]
def CreateHistogram(serie, binCount):
main_frame = QtGui.QWidget()
dpi = 100
fig = Figure((5.0, 4.0), dpi=dpi)
canvas = FigureCanvas(fig)
canvas.setParent(main_frame)
axes = fig.add_subplot(111)
mpl_toolbar = NavigationToolbar(canvas, main_frame)
hbox = QtGui.QHBoxLayout()
vbox = QtGui.QVBoxLayout()
vbox.addWidget(canvas)
vbox.addWidget(mpl_toolbar)
vbox.addLayout(hbox)
main_frame.setLayout(vbox)
# clear the axes and redraw the plot anew
#
axes.clear()
axes.hist(serie, binCount, facecolor='green')
axes.yaxis.grid(True, linestyle='-', which='major', color='lightgrey')
axes.set_axisbelow(True)
canvas.draw()
return main_frame
示例12: PlotWidget
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setParent [as 别名]
class PlotWidget(QWidget):
def __init__(self):
super(PlotWidget, self).__init__()
self.initUI()
self.data = np.arange(20).reshape([4, 5]).copy()
self.on_draw()
def initUI(self):
self.fig = Figure((5.0, 4.0), dpi=50)
self.canvas = FigureCanvas(self.fig)
self.canvas.setParent(self)
self.canvas.setFocusPolicy(Qt.StrongFocus)
self.canvas.setFocus()
# self.mpl_toolbar = NavigationToolbar(self.canvas, self)
#
# self.canvas.mpl_connect('key_press_event', self.on_key_press)
vbox = QVBoxLayout()
vbox.addWidget(self.canvas) # the matplotlib canvas
# vbox.addWidget(self.mpl_toolbar)
self.setLayout(vbox)
def on_draw(self):
self.fig.clear()
self.axes = self.fig.add_subplot(111)
# self.axes.plot(self.x, self.y, 'ro')
self.axes.imshow(self.data, interpolation='nearest')
# self.axes.plot([1,2,3])
self.canvas.draw()
def on_key_press(self, event):
print('you pressed', event.key)
# implement the default mpl key press events described at
# http://matplotlib.org/users/navigation_toolbar.html#navigation-keyboard-shortcuts
key_press_handler(event, self.canvas, self.mpl_toolbar)
示例13: plot
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setParent [as 别名]
def plot(self,datastr):
data=json.loads(unicode(datastr))
if "data" in data and "graphs" in data["data"]:
graphdata= data["data"]["graphs"]
if len(graphdata)<len(self.canvases):
for i in reversed(range(self.layout.count())):
self.layout.itemAt(i).widget().deleteLater()
self.canvases=[]
self.figures=[]
for maskindex,set in enumerate(graphdata):
if len(self.canvases)<=maskindex:
self.figures.append(plt.figure( ))
canvas=FigureCanvas(self.figures[maskindex])
canvas.setParent(self)
self.canvases.append(canvas)
self.layout.addWidget(self.canvases[maskindex])
figure=self.figures[maskindex]
figure.clf()
figure.set_frameon(False)
ax=figure.add_subplot(111)
ax.set_yscale('symlog')
ax.set_xlabel(set["columnLabels"][0],fontsize=16)
ax.set_ylabel(set["columnLabels"][1],fontsize=16)
ax.set_title( set["kind"]+" "+data["data"]['filename'])
ax.patch.set_alpha(0)
x=np.array(set["array"][0])[:]
y=np.array(set["array"][1])[:]
e=np.array(set["array"][2])[:]
ppl.plot(ax,x,y,lw=1.0)
ppl.fill_between(ax,x,y-e,y+e)
plt.subplots_adjust(bottom=0.2)
self.canvases[maskindex].draw()
示例14: PlotFDistributionDistributionFunction
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setParent [as 别名]
def PlotFDistributionDistributionFunction(dfn, dfd):
if dfn>0 and dfd>0:
main_frame = QtGui.QWidget()
dpi = 100
fig = Figure((5.0, 4.0), dpi=dpi)
canvas = FigureCanvas(fig)
canvas.setParent(main_frame)
axes = fig.add_subplot(111)
mpl_toolbar = NavigationToolbar(canvas, main_frame)
hbox = QtGui.QHBoxLayout()
vbox = QtGui.QVBoxLayout()
vbox.addWidget(canvas)
vbox.addWidget(mpl_toolbar)
vbox.addLayout(hbox)
main_frame.setLayout(vbox)
alpha = 0.0005
sequence = stats.f.isf(alpha, dfn, dfd)
x = np.linspace(-sequence, sequence, 1000)
rv = stats.f(dfn, dfd)
y = rv.cdf(x)
axes.plot(x,y)
canvas.draw()
return main_frame
else:
return False, "Serbestlik derecesi 0'dan kucuk olamaz."
#---/F DISTRIBUTION
示例15: PlotWindow
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setParent [as 别名]
class PlotWindow(QMainWindow):
def __init__(self, parent=None):
QMainWindow.__init__(self, parent)
self.setWindowTitle('Online plot')
self.create_main_frame()
self.on_draw()
def save_plot(self):
pass
def on_about(self):
pass
def on_pick(self, event):
pass
def on_draw(self):
self.axes.clear()
self.axes.grid(True)
self.canvas.draw()
def create_main_frame(self):
self.main_frame = QWidget()
self.dpi = 100
self.fig = Figure((20.0, 6.0), dpi=self.dpi)
self.canvas = FigureCanvas(self.fig)
self.canvas.setParent(self.main_frame)
self.axes = self.fig.add_subplot(111)
self.canvas.mpl_connect('pick_event', self.on_pick)
self.mpl_toolbar = NavigationToolbar(self.canvas, self.main_frame)
vbox = QVBoxLayout()
vbox.addWidget(self.canvas)
vbox.addWidget(self.mpl_toolbar)
self.main_frame.setLayout(vbox)
self.setCentralWidget(self.main_frame)