本文整理汇总了Python中matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg.setSizePolicy方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasQTAgg.setSizePolicy方法的具体用法?Python FigureCanvasQTAgg.setSizePolicy怎么用?Python FigureCanvasQTAgg.setSizePolicy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg
的用法示例。
在下文中一共展示了FigureCanvasQTAgg.setSizePolicy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ExternalWindow
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setSizePolicy [as 别名]
class ExternalWindow(QtGui.QWidget):
"""
Generic Widget to contain 1 or 2 mpl plots
"""
def __init__(self, size, num_plots=1, *args, **kwargs):
super(QtGui.QWidget, self).__init__(parent=None)
self.args = args
self.kwargs = kwargs
self.setMinimumSize(size[0], size[1])
if num_plots == 1:
self.fig, self.pltax = plt.subplots(1, num_plots, figsize=(8, 6), dpi=100)
elif num_plots == 2:
self.fig, (self.imgax, self.pltax) = plt.subplots(1, num_plots, figsize=(8, 6), dpi=100)
else:
raise NotImplementedError
self.canvas = FigureCanvas(self.fig)
self.canvas.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
self.mpl_toolbar = NavigationToolbar(self.canvas, self)
vbox = QtGui.QVBoxLayout()
vbox.addWidget(self.canvas)
vbox.addWidget(self.mpl_toolbar)
self.setLayout(vbox)
def closeEvent(self, QCloseEvent):
# for line profile plots - We want to delete the line after closing window
if "canvas" in self.kwargs.keys() and "line" in self.kwargs.keys():
self.kwargs["line"].remove()
self.kwargs["canvas"].draw()
self.close()
示例2: __init__
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setSizePolicy [as 别名]
def __init__(self, parent=None, width = 6, height = 5, dpi = 100, sharex = None, sharey = None):
self.fig = Figure(figsize = (width, height), dpi=dpi, facecolor = '#FFFFFF')
# self.ax = self.fig.add_subplot(211, sharex = sharex, sharey = sharey)
# self.ax2 = self.fig.add_subplot(212, sharex = sharex, sharey = sharey)
self.ax = self.fig.add_axes(mainAx)
self.ax2 = self.fig.add_axes(sideAx)
self.ax2.yaxis.set_major_formatter(nullfmt)
self.axList = [self.ax, self.ax2]
self.fig.subplots_adjust(left=0.1, bottom=0.1, right=0.9, top=0.9)
self.plotTitle = ''
self.xtitle="m/z"#"Drift Time (ms)"
self.ytitle="Intensity"#"Intensity"
self.ax.set_xlabel(self.xtitle, fontsize = 9)
self.ax.set_ylabel(self.ytitle, fontsize = 9)
self.grid_status = True
self.xaxis_style = 'linear'
self.yaxis_style = 'linear'
self.format_labels()
self.ax.hold(True)
FigureCanvas.__init__(self, self.fig)
FigureCanvas.setSizePolicy(self,
QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Expanding)
FigureCanvas.updateGeometry(self)
示例3: __init__
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setSizePolicy [as 别名]
def __init__(self):
self.fig = Figure()
self.ax = self.fig.add_subplot(111)
FigureCanvas.__init__(self, self.fig)
FigureCanvas.setSizePolicy(self, QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding)
FigureCanvas.updateGeometry(self)
示例4: __init__
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setSizePolicy [as 别名]
def __init__(
self,
parent=None,
title="",
xlabel="",
ylabel="",
xlim=None,
ylim=None,
xscale="linear",
yscale="linear",
width=4,
height=3,
dpi=100,
hold=False,
):
self.figure = Figure(figsize=(width, height), dpi=dpi)
self.axes = self.figure.add_subplot(111)
self.axes.set_title(title)
self.axes.set_xlabel(xlabel)
self.axes.set_ylabel(ylabel)
if xscale is not None:
self.axes.set_xscale(xscale)
if yscale is not None:
self.axes.set_yscale(yscale)
if xlim is not None:
self.axes.set_xlim(*xlim)
if ylim is not None:
self.axes.set_ylim(*ylim)
self.axes.hold(hold)
Canvas.__init__(self, self.figure)
self.setParent(parent)
Canvas.setSizePolicy(self, QSizePolicy.Expanding, QSizePolicy.Expanding)
Canvas.updateGeometry(self)
示例5: __init__
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setSizePolicy [as 别名]
def __init__(self, parent):
""" Initialization
"""
# from mpl_toolkits.axes_grid1 import host_subplot
# import mpl_toolkits.axisartist as AA
# import matplotlib.pyplot as plt
# Instantiating matplotlib Figure
self.fig = Figure()
self.fig.patch.set_facecolor('white')
if True:
self.axes = self.fig.add_subplot(111) # return: matplotlib.axes.AxesSubplot
self.axes2 = None
else:
self.axes = self.fig.add_host_subplot(111)
# Initialize parent class and set parent
FigureCanvas.__init__(self, self.fig)
self.setParent(parent)
# Set size policy to be able to expanding and resizable with frame
FigureCanvas.setSizePolicy(self, QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding)
FigureCanvas.updateGeometry(self)
# Variables to manage all lines/subplot
self._lineDict = {}
self._lineIndex = 0
# legend and color bar
self._colorBar = None
return
示例6: __init__
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setSizePolicy [as 别名]
def __init__(self, parent=None):
self.fig = Figure()
self.axes = self.fig.add_subplot(111)
FigureCanvas.__init__(self, self.fig)
#----Creation des tableaux de donnees-----
self.tableau_parametre = []
self.tableau_rdt = []
self.tableau_xHI = []
self.tableau_aI2 = []
self.tableau_aH2 = []
self.l_tableau_rdt, = self.axes.plot(self.tableau_parametre, self.tableau_rdt, color="0.25", linestyle="-", linewidth="2", label="Rendement")
self.l_tableau_xHI, = self.axes.plot(self.tableau_parametre, self.tableau_xHI,color="red", linestyle="-", linewidth="2", label="x(HI)")
self.l_tableau_aI2, = self.axes.plot(self.tableau_parametre, self.tableau_xHI, color="blue", linestyle=":", linewidth="4", label="alpha(I2)")
self.l_tableau_aH2, = self.axes.plot(self.tableau_parametre, self.tableau_xHI, color="green", linestyle="--", linewidth="3", label="alpha(H2)")
self.axes.legend()
self.axes.set_ylim(0.0, 1.0)
self.axes.set_xlabel("Rapport initial n(H2)/n(I2)")
self.setParent(parent)
FigureCanvas.setSizePolicy(self, QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding)
FigureCanvas.updateGeometry(self)
示例7: __init__
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setSizePolicy [as 别名]
def __init__(self, parent, xgrid, zgrid, xcoords, zcoords, width=3, dpi=100):
self.xgrid=xgrid
self.zgrid=zgrid
self.xcoords=xcoords
self.zcoords=zcoords
self.widthpix=width*dpi
self.substrateradius=38.1
self.subfactor=numpy.sqrt(self.substrateradius/38.1) #the axes scales are not automated,
self.fig = Figure(figsize=(width, width), dpi=dpi)
FigureCanvas.__init__(self, self.fig)
self.setParent(parent)
self.axes = self.fig.add_subplot(111, aspect=1, frame_on=False)
temp=self.axes.get_position().get_points()
self.radiusmm=self.substrateradius+4
self.pixpermm=temp[1, 0]*self.widthpix/(2.0*self.radiusmm)
self.xpixshift=(temp[0, 0]+temp[1, 0]/2.0)*self.widthpix
self.ypixshift=(temp[0, 1]+temp[1, 0]/2.0)*self.widthpix
#self.axes.set_axis_bgcolor('w') #this doesn't seem to work
self.axesformat()
# We want the axes cleared every time plot() is called
self.axes.hold(False)
self.mpl_connect('button_press_event', self.myclick)
self.inxvals=[]
self.inzvals=[]
self.exxvals=[]
self.exzvals=[]
self.includelist=[]
self.excludelist=[]
FigureCanvas.setSizePolicy(self, QSizePolicy.Fixed, QSizePolicy.Fixed)
FigureCanvas.updateGeometry(self)
示例8: __init__
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setSizePolicy [as 别名]
def __init__(self, parent=None, width=9, height=6, dpi=None):
self.fig = Figure(figsize=(width, height), facecolor=(.94,.94,.94), dpi=dpi)
FigureCanvas.__init__(self, self.fig)
self.setParent(parent)
FigureCanvas.setSizePolicy(self,
QSizePolicy.Expanding,
QSizePolicy.Expanding)
FigureCanvas.updateGeometry(self)
self.axes = self.fig.add_axes([0.06, 0.10, 0.9, 0.85], facecolor=(.94,.94,.94))
self.compute_initial_figure()
# horizontal x range span
axxspan = self.fig.add_axes([0.06, 0.05, 0.9, 0.02])
axxspan.axis([-0.2, 1.2, -0.2, 1.2])
axxspan.tick_params('y', labelright = False ,labelleft = False ,length=0)
self.xspan = SpanSelector(axxspan, self.onselectX, 'horizontal',useblit=True, span_stays=True, rectprops=dict(alpha=0.5, facecolor='blue'))
# vertical y range span
axyspan = self.fig.add_axes([0.02, 0.10, 0.01, 0.85])
axyspan.axis([-0.2, 1.2, -0.2, 1.2])
axyspan.tick_params('x', labelbottom = False ,labeltop = False ,length=0)
self.yspan = SpanSelector(axyspan, self.onselectY, 'vertical',useblit=True, span_stays=True, rectprops=dict(alpha=0.5, facecolor='blue'))
# reset x y spans
axReset = self.fig.add_axes([0.01, 0.05, 0.03, 0.03],frameon=False, )
self.bnReset = Button(axReset, 'Reset')
self.bnReset.on_clicked( self.xyReset )
# contextMenu
acExportPlot = QAction(self.tr("Export plot"), self)
FigureCanvas.connect(acExportPlot,SIGNAL('triggered()'), self, SLOT('exportPlot()') )
FigureCanvas.addAction(self, acExportPlot )
FigureCanvas.setContextMenuPolicy(self, Qt.ActionsContextMenu )
示例9: __init__
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setSizePolicy [as 别名]
def __init__(self, parent=None, width = 10, height = 12, dpi = 100, sharex = None, sharey = None):
self.fig = Figure(figsize = (width, height), dpi=dpi, facecolor = '#FFFFFF')
self.ax = Axes3D(self.fig)
# n = 100
# for c, zl, zh in [('r', -50, -25), ('b', -30, -5)]:
# xs = randrange(n, 23, 32)
# ys = randrange(n, 0, 100)
# zs = randrange(n, zl, zh)
self.ax.scatter3D(S.rand(200), S.rand(200), S.rand(200))#, c = c, alpha = 0.8)
self.ax.set_xlabel('X Label')
self.ax.set_ylabel('Y Label')
self.ax.set_zlabel('Z Label')
# self.ax = self.fig.add_subplot(111, sharex = sharex, sharey = sharey)
# self.fig.subplots_adjust(left=0.1, bottom=0.1, right=0.9, top=0.9)
self.xtitle="x-Axis"
self.ytitle="y-Axis"
self.PlotTitle = "Plot"
self.grid_status = True
self.xaxis_style = 'linear'
self.yaxis_style = 'linear'
self.format_labels()
self.ax.hold(True)
FigureCanvas.__init__(self, self.fig)
#self.fc = FigureCanvas(self.fig)
FigureCanvas.setSizePolicy(self,
QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Expanding)
FigureCanvas.updateGeometry(self)
示例10: __init__
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setSizePolicy [as 别名]
def __init__(self, spectrometers,parent=None, width=4, height=4.5, dpi=100):
self.counter = 0
self.spectrometers = spectrometers
self.fig = Figure(figsize=(width, height), dpi=dpi)
self.plots = []
self.xmins, self.xmaxs, self.ymins, self.ymaxs = [], [], [], []
self.update_paused = True
self.thread_paused_override = self.spectrometers.thread.paused
self.logscale = [semilogy_scale, semilogy_scale, semilogy_scale]
self.update_time = 50#ms
for i in range(self.spectrometers.num_spectrometers):
print i
self.plots.append(self.fig.add_subplot(self.spectrometers.num_spectrometers,1,i+1))
self.xmins.append(560)
self.xmaxs.append(600)
self.ymins.append(0.1)
self.ymaxs.append(500)
self.fig.subplots_adjust(bottom=0.15,left=0.20,top=0.9,right=0.95)
for axes in self.plots:
axes.hold(False)
FigureCanvas.__init__(self, self.fig)
self.setParent(parent)
FigureCanvas.setSizePolicy(self,QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding)
FigureCanvas.updateGeometry(self)
self.compute_initial_figure()
self.timer = QtCore.QTimer(self)
QtCore.QObject.connect(self.timer, QtCore.SIGNAL("timeout()"), self.update_figure)
self.timer.start(self.update_time) #in ms
示例11: __init__
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setSizePolicy [as 别名]
def __init__(self, parent=None, width=5, height=4, dpi=100):
self.fig1 = Figure(figsize=(width, height), dpi=dpi)
self.fig2 = Figure(figsize=(width, height), dpi=dpi)
fig3 = Figure(figsize=(width, height), dpi=dpi)
self.axes1 = self.fig1.add_subplot(223)
print self.axes1.__class__.__name__
self.axes2 = self.fig2.add_subplot(221)
# We want the axes cleared every time plot() is called
#self.axes.hold(False)
#self.axes2.hold(False)
self.compute_initial_figure()
#
FigureCanvas.__init__(self, self.fig1)
self.setParent(parent)
FigureCanvas.setSizePolicy(self,
QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Expanding)
FigureCanvas.updateGeometry(self)
t = arange(0.0, 1.0, 0.01)
s = sin(2*pi*t)
axes3 = fig3.add_subplot(1, 2, 2)
axes3.plot(t,s)
axes3.set_figure(self.fig1)
self.fig1.add_axes(axes3)
示例12: __init__
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setSizePolicy [as 别名]
def __init__(self):
self.fig = Figure(facecolor="white", frameon=False)
self.ax = self.fig.add_subplot(111)
FigureCanvas.__init__(self, self.fig)
FigureCanvas.setSizePolicy(self, QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding)
FigureCanvas.updateGeometry(self)
示例13: __init__
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setSizePolicy [as 别名]
def __init__(self, parent=None, width=5, height=4, dpi=100):
fig = Figure(figsize=(width, height), dpi=dpi)
# We want the axes cleared every time plot() is called
self.axes = fig.add_subplot(1, 1, 1)
self.axes.hold(False)
FigureCanvas.__init__(self, fig)
# self.figure
self.setParent(parent)
FigureCanvas.setSizePolicy(self,
QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Expanding)
FigureCanvas.updateGeometry(self)
self._title = ''
self.title_font = {'family': 'serif', 'fontsize': 10}
self._title_size = 0
self.figure.subplots_adjust(top=0.95, bottom=0.15)
window_brush = self.window().palette().window()
fig.set_facecolor(brush_to_color_tuple(window_brush))
fig.set_edgecolor(brush_to_color_tuple(window_brush))
self._active = False
示例14: PlotDialog
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setSizePolicy [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)
示例15: MplAxes
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setSizePolicy [as 别名]
class MplAxes(object):
def __init__(self, parent):
self._parent = parent
self._parent.resizeEvent = self.resize_graph
self.create_axes()
self.redraw_figure()
def create_axes(self):
self.figure = Figure(None, dpi=100)
self.canvas = FigureCanvas(self.figure)
self.canvas.setParent(self._parent)
axes_layout = QtGui.QVBoxLayout(self._parent)
axes_layout.setContentsMargins(0, 0, 0, 0)
axes_layout.setSpacing(0)
axes_layout.setMargin(0)
axes_layout.addWidget(self.canvas)
self.canvas.setSizePolicy(QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Expanding)
self.canvas.updateGeometry()
self.axes = self.figure.add_subplot(111)
def resize_graph(self, event):
new_size = event.size()
self.figure.set_size_inches([new_size.width() / 100.0, new_size.height() / 100.0])
self.redraw_figure()
def redraw_figure(self):
self.figure.tight_layout(None, 0.8, None, None)
self.canvas.draw()