本文整理汇总了Python中matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg.draw方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasQTAgg.draw方法的具体用法?Python FigureCanvasQTAgg.draw怎么用?Python FigureCanvasQTAgg.draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg
的用法示例。
在下文中一共展示了FigureCanvasQTAgg.draw方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CreateLinePlot
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import draw [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
示例2: PlotDialog
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import draw [as 别名]
class PlotDialog(QDialog,Ui_Widget):
def __init__(self, qApp, parent=None):
super(PlotDialog, self).__init__(parent)
self.server=Pyro4.Proxy("PYRONAME:simple_server")
self.__app = qApp
self.setupUi(self)
self.setupTimer()
self.dpi = 72
self.fig = Figure((9.1, 5.2), dpi=self.dpi)
self.canvas = FigureCanvas(self.fig)
self.canvas.setParent(self)
self.verticalLayout.insertWidget(0,self.canvas)
self.canvas.setSizePolicy(QSizePolicy.Expanding,QSizePolicy.Expanding)
self.axes = self.fig.add_subplot(111)
def update(self):
list=self.server.fetch_data()
self.axes.cla()
if len(list)<51:
self.axes.plot(list)
else:
self.axes.plot(list[-50:])
self.canvas.draw()
#print list
#for debugging
def setupTimer(self):
#Create a QT Timer that will timeout every half-a-second
#The timeout is connected to the update function
self.timer = QTimer()
self.timer.timeout.connect(self.update)
self.timer.start(500)
示例3: TestDialog
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import draw [as 别名]
class TestDialog( QDialog, Ui_dlgMPLTest ):
def __init__( self, parent = None ):
super( TestDialog, self ).__init__( parent )
self.setupUi( self )
# initialize mpl plot
self.figure = Figure()
#self.figure.set_figsize_inches( ( 4.3, 4.2 ) )
self.axes = self.figure.add_subplot( 111 )
self.figure.suptitle( "Frequency distribution", fontsize = 12 )
self.axes.grid( True )
self.canvas = FigureCanvas( self.figure )
layout = QVBoxLayout()
self.widgetPlot.setLayout(layout)
layout.addWidget(self.canvas)
#self.canvas.setParent( self.widgetPlot )
# draw mpl plot
#self.axes.clear()
#self.axes.grid( True )
#self.figure.suptitle( "Frequency distribution", fontsize = 12 )
self.axes.set_ylabel( "Count", fontsize = 8 )
self.axes.set_xlabel( "Values", fontsize = 8 )
x = [ 4, 1, 5, 3, 3, 2, 3, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1 ]
n, bins, pathes = self.axes.hist( x, 18, alpha=0.5, histtype = "bar" )
self.canvas.draw()
self.setWindowTitle( self.tr( "MPL test" ) )
示例4: MathTextLabel
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import draw [as 别名]
class MathTextLabel(qt.QWidget):
def __init__(self, mathText, parent=None, **kwargs):
qt.QWidget.__init__(self, parent, **kwargs)
l=qt.QVBoxLayout(self)
l.setContentsMargins(0,0,0,0)
r,g,b,a=self.palette().base().color().getRgbF()
self._figure=Figure(edgecolor=(r,g,b), facecolor=(r,g,b))
self._canvas=FigureCanvas(self._figure)
l.addWidget(self._canvas)
self._figure.clear()
text=self._figure.suptitle(
mathText,
x=0.0,
y=1.0,
horizontalalignment='left',
verticalalignment='top',
size=qt.qApp.font().pointSize()*3)
self._canvas.draw()
(x0,y0),(x1,y1)=text.get_window_extent().get_points()
w=x1-x0; h=y1-y0
#self._figure.set_size_inches(w/4, h/4)
self.setFixedSize(w,h)
示例5: TrimCanvas
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import draw [as 别名]
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)]
示例6: RewardWidget
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import draw [as 别名]
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)
示例7: Window
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import draw [as 别名]
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()
示例8: Window
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import draw [as 别名]
class Window(QtGui.QDialog):
def __init__(self, parent=None):
super(Window, self).__init__(parent)
self.figure = plt.figure()
self.canvas = FigureCanvas(self.figure)
self.toolbar = NavigationToolbar(self.canvas, self)
self.button = QtGui.QPushButton('Plot')
self.button.clicked.connect(self.plot)
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(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()
示例9: PlotOverview
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import draw [as 别名]
class PlotOverview(qtgui.QWidget):
def __init__(self, db):
self.db = db
self.fig = Figure()
self.canvas = FigureCanvas(self.fig)
super().__init__()
lay_v = qtgui.QVBoxLayout()
self.setLayout(lay_v)
self.year = qtgui.QComboBox()
self.year.currentIndexChanged.connect(self.plot)
lay_h = qtgui.QHBoxLayout()
lay_h.addWidget(self.year)
lay_h.addStretch(1)
lay_v.addLayout(lay_h)
lay_v.addWidget(self.canvas)
self.update()
def update(self):
constraints = self.db.get_constraints()
current_year = self.year.currentText()
self.year.clear()
years = [y for y in range(min(constraints['start_date']).year, datetime.datetime.now().year + 1)]
self.year.addItems([str(y) for y in years])
try:
self.year.setCurrentIndex(years.index(current_year))
except ValueError:
self.year.setCurrentIndex(len(years) - 1)
def plot(self):
self.fig.clf()
ax = self.fig.add_subplot(111)
worked = np.zeros((12, 34)) + np.nan
year = int(self.year.currentText())
for month in range(12):
for day in range(calendar.monthrange(year, month + 1)[1]):
date = datetime.date(year, month + 1, day + 1)
if date < datetime.datetime.now().date():
t = self.db.get_worktime(date).total_seconds() / 60.0 - self.db.get_desiredtime(date)
worked[month, day] = t
ax.text(day, month, re.sub('0(?=[.])', '', ('{:.1f}'.format(t / 60))), ha='center', va='center')
worked[:, 32:] = np.nansum(worked[:, :31], axis=1, keepdims=True)
for month in range(12):
ax.text(32.5, month, re.sub('0(?=[.])', '', ('{:.1f}'.format(worked[month, -1] / 60))), ha='center', va='center')
ax.imshow(worked, vmin=-12*60, vmax=12*60, interpolation='none', cmap='coolwarm')
ax.set_xticks(np.arange(31))
ax.set_yticks(np.arange(12))
ax.set_xticklabels(1 + np.arange(31))
ax.set_yticklabels(calendar.month_name[1:])
self.fig.tight_layout()
self.canvas.draw()
示例10: dibujante2
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import draw [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()
示例11: Main
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import draw [as 别名]
class Main(QtGui.QMainWindow, _class_ui):
def __init__(self, parent=None):
QtGui.QMainWindow.__init__(self,parent)
self.setupUi(self)
self.widget = QtGui.QWidget()
self.layout = QtGui.QVBoxLayout(self.widget)
self.figure = plt.figure()
self.canvas = FigureCanvas(self.figure)
self.toolbar = NavigationToolbar(self.canvas, self)
self.layout.addWidget(self.toolbar)
self.layout.addWidget(self.canvas)
self.setLayout(self.layout)
self.setCentralWidget(self.widget)
self.data = data
self.ancho = 0.3
self.posicion = np.arange(len(self.data))
self.ax = self.figure.add_subplot(111)
self.bars = self.ax.bar(self.posicion, self.data, self.ancho, color='#6a7ea6')
self.ax.set_yticks(range(0, 7)) #máximo de puntos eje Y
self.ax.set_xticks(self.posicion +self.ancho /2) #posición eje X
self.ax.set_xticklabels(labels) #mostrar etiquetas
self.ax.set_xlim(-0.5, len(self.data)) #posición canvas
self.canvas.draw()
示例12: __init__
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import draw [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()
示例13: CreateAnovaResult
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import draw [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
示例14: CreateRegression
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import draw [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
示例15: addSkeletonWindow
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import draw [as 别名]
def addSkeletonWindow(self):
t_start = 1917 # start frame
t_end = 2130 # end frame
data = pd.read_csv('../inputs/Smart-first_phase_NaN-zeros.csv') # only coordinate data
df = data.loc[t_start:t_end,'Shoulder_left_x':'Ankle_right_z']
data = df.values.tolist()
def chunks(l, n):
return [l[i:i+n] for i in range(0, len(l), n)]
newData = []
for line in data:
newData.append(chunks(line, 3))
figure = render.renderSkeleton(newData)
layout = QtGui.QVBoxLayout()
canvas = FigureCanvas(figure)
toolbar = NavigationToolbar(canvas, self)
self.layout.addWidget(toolbar)
self.layout.addWidget(canvas)
button = QtGui.QPushButton('Plot')
self.layout.addWidget(button)
self.setLayout(self.layout)
canvas.draw()
plt.show()