当前位置: 首页>>代码示例>>Python>>正文


Python FigureCanvasQTAgg.setGeometry方法代码示例

本文整理汇总了Python中matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg.setGeometry方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasQTAgg.setGeometry方法的具体用法?Python FigureCanvasQTAgg.setGeometry怎么用?Python FigureCanvasQTAgg.setGeometry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg的用法示例。


在下文中一共展示了FigureCanvasQTAgg.setGeometry方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: MplGraphWidget

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setGeometry [as 别名]
class MplGraphWidget(QtGui.QWidget):

    def __init__(self, parent=None, width=3, height=3, dpi=100):

        super(MplGraphWidget, self).__init__(parent)

        self._dataY = np.array([])
        self._dataX = np.array([])

        self._spCols = 1
        self._spRows = 1
        self.all_sp_axes = []
        self.fig = Figure(figsize=(width,height), dpi=dpi)
        self.all_sp_axes.append(self.fig.add_subplot(self._spCols, self._spRows, 1))
        self.fig.set_frameon(False)
        self.fig.set_tight_layout(True)

        self.canvas = Canvas(self.fig)

        self._navBarOn = True
        self.mpl_toolbar = NavigationToolbar(self.canvas, parent)

        self.canvas.mpl_connect('key_press_event', self.on_key_press)
        self.canvas.mpl_connect('button_press_event', self.on_button_press)
        self.canvas.mpl_connect('motion_notify_event', self.on_mouse_move)
        self.canvas.setFocusPolicy(QtCore.Qt.ClickFocus)
        self.canvas.setFocus()

        self.canvas.setParent(parent)
        self.canvas.clearMask()
        self.canvas.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
        self.canvas.updateGeometry()

        vbox = QtGui.QVBoxLayout()
        vbox.addWidget(self.canvas)
        if self._navBarOn:
            vbox.addWidget(self.mpl_toolbar)
        self.setLayout(vbox)

    key_pressed = QtCore.pyqtSignal(object, name='keyPressed')

    def on_key_press(self, event):
        self.key_pressed.emit(event)
        key_press_handler(event, self.canvas, self.mpl_toolbar)

    button_pressed = QtCore.pyqtSignal(object, name='buttonPressed')

    def on_button_press(self, event):
        self.button_pressed.emit(event)
        key_press_handler(event, self.canvas, self.mpl_toolbar)

    mouse_move = QtCore.pyqtSignal(object, name='mouseMoved')

    def on_mouse_move(self, event):
        self.mouse_move.emit(event)
        key_press_handler(event, self.canvas, self.mpl_toolbar)

    def get_icon(name):
        """Return Matplotlib icon *name*"""
        return QtGui.QIcon(osp.join(rcParams['datapath'], 'images', name))

    def generateNewAxes(self):
        for ax in self.all_sp_axes:
            self.fig.delaxes(ax)
        self.all_sp_axes = []
        numOfAxes = (self._spRows*self._spCols)+1
        for i in np.arange(1,numOfAxes):
            self.all_sp_axes.append(self.fig.add_subplot(self._spRows, self._spCols, i))
        self.canvas.setGeometry(100, 100, 300, 300)  #Used to update the new number of axes
        self.canvas.updateGeometry()  #This will bring the size of the canvas back to the original (defined by the vbox)

    spRowsChanged = QtCore.pyqtSignal(int)

    def getspRows(self):
        return self._spRows

    @QtCore.pyqtSlot(int)
    def setspRows(self, spRows):
        self._spRows = spRows
        self.generateNewAxes()
        self.spRowsChanged.emit(spRows)

    def resetspRows(self):
        self.setspRows(1)

    spRows = QtCore.pyqtProperty(int, getspRows, setspRows, resetspRows)

    spColsChanged = QtCore.pyqtSignal(int)

    def getspCols(self):
        return self._spCols

    @QtCore.pyqtSlot(int)
    def setspCols(self, spCols):
        self._spCols = spCols
        self.generateNewAxes()
        self.spRowsChanged.emit(spCols)

    def resetspCols(self):
        self.setspCols(1)
#.........这里部分代码省略.........
开发者ID:georgedimitriadis,项目名称:themeaningofbrain,代码行数:103,代码来源:mplgraphwidget.py

示例2: DiagramaDeRafagasyManiobrasDialog

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setGeometry [as 别名]
class DiagramaDeRafagasyManiobrasDialog(QFrame, layout_DiagramaDeRafagasyManiobras.Ui_Dialog):

    def __init__(self, parent=None):
        super(DiagramaDeRafagasyManiobrasDialog, self).__init__(parent)
        self.setupUi(self)
        self.setWindowTitle(__appName__)

        # Define input unit's label for SI and IM
        self.length_label = {'IM': 'ft', 'SI': 'm'}
        self.area_label = {'IM': 'ft^2', 'SI': 'm^2'}
        self.weight_label = {'IM': 'lb', 'SI': 'kg'}
        self.speed_label = {'IM': 'ft/s', 'SI': 'm/s'}
        self.den_label = {'IM': 'slug/ft^2', 'SI': 'kg/m^3'}

        self.ft2m = 0.3048
        self.lb2kg = 0.453592

        datos = {
            'CAM': {'SI': 2.461, 'IM': 2.461/self.ft2m},
            'sw': {'SI': 60, 'IM': 60 / self.ft2m / self.ft2m},
            'a3D': 5.0037,
            'MTOW': {'SI': 23000, 'IM': 23000 / self.lb2kg},
            'MLW': {'SI': 23000, 'IM': 23000 / self.lb2kg},
            'MZFW': {'SI': 16376.0, 'IM': 16376.0 / self.lb2kg},
            'Vc': {'SI': 151.93, 'IM': 151.93 / self.ft2m},
            'clmax': 1.2463,
            'clmax_flap': 1.499,
            'clmin': -0.75*1.2463,
            'Zmo': {'SI': 9999.2, 'IM': 9999.2 / self.ft2m}
        }
        w = {'SI': 20000, 'IM': 20000 / self.lb2kg}
        h = {'SI': 5000, 'IM': 5000 / self.ft2m}
        den = {'SI': 1.225, 'IM': 1.225 / self.lb2kg * self.ft2m**3}
        self.diagramas = Diagramas(datos, w, h, den, units='SI')
        self.update_units()
        self.atmosfera_estandar_dialog = AtmosferaEstandarDialog(unit=self.units)

        self.fig1 = Figure((5.0, 3.0), dpi=72, facecolor=(1, 1, 1), edgecolor=(0, 0, 0))
        self.fig1.subplots_adjust(left=0.1, right=0.9, top=0.9, bottom=0.25)
        self.axes1 = self.fig1.add_subplot(111)
        self.axes1.set_ylabel('n')
        self.axes1.set_xlabel(self.speed_label[self.units])
        self.axes1.set_title('Diagrama de Maniobras')
        self.axes1.ticklabel_format(style="sci", scilimits=(0, 0), axis="both")  # , useOffset=True,useLocale=True)
        self.axes1.tick_params(axis="both", direction='in', length=6, width=2, labelsize="medium")

        self.fig2 = Figure(dpi=72, facecolor=(1, 1, 1), edgecolor=(0, 0, 0))
        self.fig2.subplots_adjust(left=0.1, right=0.9, top=0.9, bottom=0.25)
        self.axes2 = self.fig2.add_subplot(111)
        self.axes2.set_ylabel('n')
        self.axes2.ticklabel_format(style='sci', scilimits=(0, 0), axis="both")
        self.axes2.set_xlabel(self.speed_label[self.units])
        self.axes2.set_title('Diagrama de Rafagas')

        self.fig3 = Figure(dpi=72, facecolor=(1, 1, 1), edgecolor=(0, 0, 0))
        self.fig3.subplots_adjust(left=0.1, right=0.9, top=0.9, bottom=0.25)
        self.axes3 = self.fig3.add_subplot(111)
        self.axes3.set_ylabel('n')
        self.axes3.ticklabel_format(style='sci', scilimits=(0, 0), axis="both")
        self.axes3.set_xlabel(self.speed_label[self.units])
        self.axes3.set_title('Diagrama de Rafagas y maniobras')

        # generate the canvas to display the plot
        self.canvas1 = FigureCanvas(self.fig1)
        self.canvas1.setParent(self.manoeuvre_tab)
        self.canvas1.show()
        self.canvas2 = FigureCanvas(self.fig2)
        self.canvas2.setParent(self.gust_tab)
        self.canvas2.show()
        self.canvas3 = FigureCanvas(self.fig3)
        self.canvas3.setParent(self.combined_tab)
        self.canvas3.show()

        # SIGNALS & SLOTS
        self.connect(self.IM_radioButton, SIGNAL("clicked()"), self.update_units)
        self.connect(self.SI_radioButton, SIGNAL("clicked()"), self.update_units)
        self.connect(self.Altura_Button, SIGNAL("clicked()"), self.seleccionAltura)
        self.connect(self.grafiacar_pushButton, SIGNAL("clicked()"), self.calculos())

        self.CAM_lineEdit.editingFinished.connect(lambda: self.lecturadatos(self.diagramas.CAM, float(self.CAM_lineEdit.text()), self.ft2m))
        self.sw_lineEdit.editingFinished.connect(lambda: self.lecturadatos(self.diagramas.sw, float(self.sw_lineEdit.text()), self.ft2m**2))
        self.MTOW_lineEdit.editingFinished.connect(lambda: self.lecturadatos(self.diagramas.MTOW, float(self.MTOW_lineEdit.text()), self.lb2kg))
        self.MLW_lineEdit.editingFinished.connect(lambda: self.lecturadatos(self.diagramas.MLW, float(self.MLW_lineEdit.text()), self.lb2kg))
        self.MZFW_lineEdit.editingFinished.connect(lambda: self.lecturadatos(self.diagramas.MZFW, float(self.MZFW_lineEdit.text()), self.lb2kg))

        self.a3D_lineEdit.editingFinished.connect(lambda: self.lecturadatos(self.diagramas.a3D, float(self.a3D_lineEdit.text())))
        self.clmax_lineEdit.editingFinished.connect(lambda: self.lecturadatos(self.diagramas.clmax, float(self.clmax_lineEdit.text())))
        self.clmax_flap_lineEdit.editingFinished.connect(lambda: self.lecturadatos(self.diagramas.clmax_flap, float(self.clmax_flap_lineEdit.text())))

        self.Zmo_lineEdit.editingFinished.connect(lambda: self.lecturadatos(self.diagramas.Zmo, float(self.Zmo_lineEdit.text()), self.ft2m))
        self.Vc_lineEdit.editingFinished.connect(lambda: self.lecturadatos(self.diagramas.Vc, float(self.Vc_lineEdit.text()), self.ft2m))

        self.W_lineEdit.editingFinished.connect(lambda: self.lecturadatos(self.diagramas.W, float(self.W_lineEdit.text()), self.lb2kg))
        self.h_lineEdit.editingFinished.connect(lambda: self.lecturadatos(self.diagramas.h, float(self.h_lineEdit.text()), self.ft2m))
        self.den_lineEdit.editingFinished.connect(lambda: self.lecturadatos(self.diagramas.den, float(self.den_lineEdit.text()), self.lb2kg / self.ft2m**3))

        self.grafiacar_pushButton.clicked.connect(self.calculos)

    def resizeEvent(self, event):
        self.canvas1.setGeometry(self.PlotArea.rect())
#.........这里部分代码省略.........
开发者ID:enritoomey,项目名称:DiagramaDeRafagasyManiobras,代码行数:103,代码来源:DiagramaDeRafagasyManiobras_app.py

示例3: Ui_Monitor

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setGeometry [as 别名]
class Ui_Monitor(object):
    def setupUi(self, Monitor):
        Monitor.setObjectName(_fromUtf8("Monitor"))
        Monitor.resize(649, 388)
        self._plabel = []
        self._port = []
        self._display = []
        ## port
        self.SetPort(Monitor)
        # port label
        self.SetLabel(Monitor)
        # lcd number
        self.SetLcdDisplay(Monitor)

        font = QtGui.QFont()
        font.setPointSize(11)

        self._start = QtGui.QPushButton(Monitor)
        self._start.setGeometry(QtCore.QRect(10, 240, 91, 21))
        self._start.setFont(font)
        self._start.setObjectName(_fromUtf8("_start"))
        self._stop = QtGui.QPushButton(Monitor)
        self._stop.setGeometry(QtCore.QRect(10, 270, 91, 21))
        self._stop.setFont(font)
        self._stop.setObjectName(_fromUtf8("_stop"))
        self._quit = QtGui.QPushButton(Monitor)
        self._quit.setGeometry(QtCore.QRect(10, 300, 91, 21))
        self._quit.setFont(font)
        self._quit.setObjectName(_fromUtf8("_quit"))

        # matplotlib canvas
        self._fig = Figure(facecolor="whitesmoke")
        self.plot = FigureCanvas(self._fig)
        self.plot.setGeometry(QtCore.QRect(120, 10, 521, 371))
        self.plot.setObjectName(_fromUtf8("monitor"))
        self.plot.setParent(Monitor)

        self.retranslateUi(Monitor)
        QtCore.QObject.connect(self._quit, QtCore.SIGNAL(_fromUtf8("clicked()")), Monitor.close)
        QtCore.QMetaObject.connectSlotsByName(Monitor)

    def retranslateUi(self, Monitor):
        Monitor.setWindowTitle(_translate("Monitor", "Form", None))
        self._start.setText(_translate("Monitor", "Start", None))
        self._stop.setText(_translate("Monitor", "Stop", None))
        self._quit.setText(_translate("Monitor", "Quit", None))

    ## set port label
    def SetLabel(self, mainwin):
        numoflabel = 3
        font = QtGui.QFont()
        font.setPointSize(11)
        font.setBold(False)
        font.setItalic(False)
        font.setWeight(50)

        for i in range(numoflabel):
            self._plabel.append( QtGui.QLabel(mainwin) )
        self._plabel[0].setGeometry(QtCore.QRect(10, 30, 101, 21))
        self._plabel[1].setGeometry(QtCore.QRect(10, 70, 101, 21))
        self._plabel[2].setGeometry(QtCore.QRect(10, 110, 101, 21))

        for i in range(len(self._plabel)):
            self._plabel[i].setFont(font)
            self._plabel[i].setText(_fromUtf8( "Port %i" %(i+1) ))
            self._plabel[i].setTextFormat(QtCore.Qt.AutoText)
            self._plabel[i].setScaledContents(False)
            self._plabel[i].setAlignment(QtCore.Qt.AlignCenter)
            self._plabel[i].setWordWrap(False)
            self._plabel[i].setObjectName(_fromUtf8( "_pLabel%i" %(i+1) ))

    ## set port address
    def SetPort(self, mainwin):
        numofport = 3
        for i in range(numofport):
            self._port.append( QtGui.QSpinBox(mainwin) )

        self._port[0].setGeometry(QtCore.QRect(10, 10, 101, 21))
        self._port[0].setProperty("value", 20)
        self._port[1].setGeometry(QtCore.QRect(10, 50, 101, 21))
        self._port[1].setProperty("value", 6)
        self._port[2].setGeometry(QtCore.QRect(10, 90, 101, 21))
        self._port[2].setProperty("value", 12)
        for i in range(len(self._port)):
            self._port[i].setObjectName(_fromUtf8("_port%i" %(i+1)))


    ## set lcd display
    def SetLcdDisplay(self, mainwin):
        numoflcd = 3
        font = QtGui.QFont()
        font.setFamily(_fromUtf8("Symbol"))
        font.setPointSize(13)
        font.setBold(True)
        font.setWeight(75)

        for i in range(numoflcd):
            self._display.append( QtGui.QLCDNumber(mainwin) )

        self._display[0].setGeometry(QtCore.QRect(10, 140, 91, 16))
#.........这里部分代码省略.........
开发者ID:kanouyou,项目名称:daqhts,代码行数:103,代码来源:PyMonitorGui.py

示例4: GNSSAzEl_window

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setGeometry [as 别名]
class GNSSAzEl_window(QtGui.QMainWindow, Ui_GNSSAzElWindow ):
    def __init__(self):
        super(GNSSAzEl_window, self).__init__()
        self.setupUi(self)
        self.init_Ui()
 
    def init_Ui(self):

        self.create_menuActions()
        self.btn_close.clicked.connect(self.close)

        self.dpi = 100
        self.fig = Figure((6.6, 6.6), dpi=self.dpi)
        self.fig.patch.set_facecolor('none')
        self.canvas = FigureCanvas(self.fig)
        # Position as left, top, width, height
        self.canvas.setGeometry(QtCore.QRect(40,60, 600, 600))  
        self.canvas.setParent(self)
        self.drawAzElPlt()

        self.checkBoxGPS.clicked.connect(self.refreshAzElPlt)
        self.checkBoxGLONASS.clicked.connect(self.refreshAzElPlt)
        self.checkBoxGALILEO.clicked.connect(self.refreshAzElPlt)
        self.checkBoxBEIDOU.clicked.connect(self.refreshAzElPlt)

        self.refreshtimer = QtCore.QTimer()
        self.refreshtimer.start(5000) #ms
        self.refreshtimer.timeout.connect(self.refreshAzElPlt)

        self.btn_close.clicked.connect(self.refreshtimer.stop)
            
    def drawAzElPlt(self):
	"""
	Draws the GNSS Az-El plot.

	"""
 
        self.grid=rc('grid', color='green', linewidth=0.5, linestyle='-')
        self.grid=rc('xtick', labelsize=15)
        self.grid=rc('ytick', labelsize=10)

        self.ax = self.fig.add_axes([0.1, 0.1, 0.8, 0.8], projection='polar', axisbg='#d5de9c')
        self.ax.set_rmax(90)

        self.ax.set_rgrids([10,20,30,40,50,60,70,80,90], angle=0)
        self.ax.set_theta_offset(0.5*math.pi)
        self.ax.set_theta_direction(-1)

        self.ax.set_title("GNSS satellites on the local horizon",va='bottom', )
        self.ax.set_yticklabels(map(str, range(80, 0, -10)))
        self.ax.set_xticklabels(['N', '', 'E', '', 'S', '', 'W', ''])

        self.ax.set_autoscalex_on(False)
        self.ax.set_autoscaley_on(False)

        if self.checkBoxGPS.isChecked() == True :
            [GPSname, phi_GPS, r_GPS] = satellites.SatCompute('visible', 'GPS')  # fills the list with all GPS satellites
            GPSname = [j.split()[-2].replace("(","" ) + j.split()[-1].replace(")" ,"") for j in GPSname] # shortens the displayed satellites' names on the plot
            self.ax.plot(phi_GPS,r_GPS, 'ro',label='GPS')
            for i,txt in enumerate(GPSname):
                self.ax.annotate(txt,(phi_GPS[i],r_GPS[i]))

        if self.checkBoxGLONASS.isChecked() == True:
            [GLONASSname, phi_GLONASS, r_GLONASS] = satellites.SatCompute('visible', 'COSMOS')  # fills the list with all GLONASS satellites
            GLONASSname = [j[13:16] for j in GLONASSname]
            self.ax.plot(phi_GLONASS, r_GLONASS, 'bo', label='GLONASS')
            for i, txt in enumerate(GLONASSname):
                self.ax.annotate(txt, (phi_GLONASS[i], r_GLONASS[i]))

        if self.checkBoxGALILEO.isChecked() == True:
            [GALILEOname, phi_GALILEO, r_GALILEO] = satellites.SatCompute('visible', 'GSAT')  # fills the list with all GALILEO satellites
            GALILEOname = [j.split()[-2].replace("(","" ) + j.split()[-1].replace(")" ,"") for j in GALILEOname]
            self.ax.plot(phi_GALILEO, r_GALILEO, 'go', label='GALILEO')
            for i, txt in enumerate(GALILEOname):
                self.ax.annotate(txt, (phi_GALILEO[i], r_GALILEO[i]))
        if self.checkBoxBEIDOU.isChecked() == True:
            [BEIDOUname, phi_BEIDOU, r_BEIDOU] = satellites.SatCompute('visible','BEIDOU')  # fills the list with all BEIDOU satellites
            BEIDOUname = [ j.split()[-1] for j in BEIDOUname]
            self.ax.plot(phi_BEIDOU, r_BEIDOU, 'ko', label='BEIDOU')
            for i, txt in enumerate(BEIDOUname):
                self.ax.annotate(txt, (phi_BEIDOU[i], r_BEIDOU[i]))

        self.canvas.draw()

    def refreshAzElPlt(self):
        """
	    Refreshes the drawn plot
	"""
        self.ax.clear()
        self.drawAzElPlt()

        
    def create_menuActions(self):
        """
        Creates actions for the menubar of the GNSS Az-El window.
        :return: Nothing
        """
        save_file_action = self.create_action("&Save current view",
            shortcut="Ctrl+S", slot=self.save_AzElPlot, 
            tip="Saves current Azimuth-Elevation view as an image.")
#.........这里部分代码省略.........
开发者ID:varenius,项目名称:salsa,代码行数:103,代码来源:main.py


注:本文中的matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg.setGeometry方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。