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


Python NavigationToolbar2QTAgg.hide方法代码示例

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


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

示例1: MPlotWidget

# 需要导入模块: from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.NavigationToolbar2QTAgg import hide [as 别名]
class MPlotWidget(QtGui.QWidget):
    def __init__(self, parent=None):
        super(MPlotWidget, self).__init__(parent)

        self.figure = plt.figure()
        self.canvas = FigureCanvas(self.figure)

        self.toolbar = NavigationToolbar(self.canvas, self)
        self.toolbar.hide()

        self.plotbutton = QtGui.QPushButton('Plot')

        self.zoombutton = QtGui.QPushButton('Zoom')
        self.zoombutton.clicked.connect(self.zoom)

        self.panbutton = QtGui.QPushButton('Pan')
        self.panbutton.clicked.connect(self.pan)

        self.homebutton = QtGui.QPushButton('Home')
        self.homebutton.clicked.connect(self.home)

        self.savebutton = QtGui.QPushButton('Save')
        self.savebutton.clicked.connect(self.save)

        layout = QtGui.QVBoxLayout()

        layout.addWidget(self.toolbar)
        layout.addWidget(self.canvas)

        buttonbox = QtGui.QHBoxLayout()
        buttonbox.addWidget(self.plotbutton)
        buttonbox.addWidget(self.zoombutton)
        buttonbox.addWidget(self.panbutton)
        buttonbox.addWidget(self.homebutton)
        buttonbox.addWidget(self.savebutton)

        layout.addLayout(buttonbox)
        self.setLayout(layout)

        self.ax = self.figure.add_subplot(111)
        self.ax.hold(False)

    def home(self):
        self.toolbar.home()
    def zoom(self):
        self.toolbar.zoom()
    def pan(self):
        self.toolbar.pan()
    def save(self):
        self.figure.savefig('1.png')

    """
开发者ID:proskurin,项目名称:Sysan_Lab3,代码行数:54,代码来源:mplotwidget.py

示例2: Window

# 需要导入模块: from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.NavigationToolbar2QTAgg import hide [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.toolbar.hide()
 
        # Just some button 
        self.button = QtGui.QPushButton('Plot')
        self.button.clicked.connect(self.plot)
 
        self.button1 = QtGui.QPushButton('Zoom')
        self.button1.clicked.connect(self.zoom)
         
        self.button2 = QtGui.QPushButton('Pan')
        self.button2.clicked.connect(self.pan)
         
        self.button3 = QtGui.QPushButton('Home')
        self.button3.clicked.connect(self.home)
 
 
        # set the layout
        layout = QtGui.QVBoxLayout()
        layout.addWidget(self.toolbar)
        layout.addWidget(self.canvas)
        layout.addWidget(self.button)
        layout.addWidget(self.button1)
        layout.addWidget(self.button2)
        layout.addWidget(self.button3)
        self.setLayout(layout)
 
    def home(self):
        self.toolbar.home()
    def zoom(self):
        self.toolbar.zoom()
    def pan(self):
        self.toolbar.pan()
         
    def plot(self):
        ''' plot some random stuff '''
        data = [random.random() for i in range(25)]
        ax = self.figure.add_subplot(111)
        ax.hold(False)
        ax.plot(data, '*-')
        self.canvas.draw()
开发者ID:SebastianRoll,项目名称:process-simulator-gui,代码行数:51,代码来源:zoompan_matplotlib.py

示例3: Window

# 需要导入模块: from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.NavigationToolbar2QTAgg import hide [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.toolbar.hide()
 
##        # Start Button
##        self.button = QtGui.QPushButton('Start')
##        self.button.clicked.connect(self.plot)
##        
        # set the layout
        layout = QtGui.QVBoxLayout()
        layout.addWidget(self.canvas)
##        layout.addWidget(self.button)
        self.setLayout(layout)

        global ser, Array, num_rows, num_cols, Matrix, count, sensor_num
        ser = sensorInit()
        num_rows = 7
        num_cols = 4
        Array = bytearray(num_rows*num_cols)
        Matrix = np.zeros((num_cols,num_rows))
        
        count = 33
        sensor_num = 24
        #timer info
        self.timer = QtCore.QBasicTimer()
        self.timer.start(count, self)
        self.step = 0

    def timerEvent(self, event):
        if event.timerId() == self.timer.timerId():
            self.update()
            Array = readSensors(ser, sensor_num)
            Matrix = matrixConvert(Array, num_rows, num_cols)
            ax = self.figure.add_subplot(111)
            ax.imshow(Matrix, interpolation='nearest', cmap='Spectral')
            self.canvas.draw()
            super(Window, self).timerEvent(event)
开发者ID:yuvashankar,项目名称:Capstone,代码行数:46,代码来源:QT_PY2.py

示例4: Grafica

# 需要导入模块: from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.NavigationToolbar2QTAgg import hide [as 别名]
class Grafica(QWidget):

    valores = (20, 35, 30, 35, 27) # valores de ejemplo


    def __init__(self, parent=None):
        super(Grafica, self).__init__()

        # FIGUREANDO
        self.ordenadas = np.arange(5)
        self.width = 1       # the width of the bars
        self.figure, self.ax = plt.subplots()
        #self.figure = plt.figure()
        self.line = self.ax.bar(self.ordenadas, self.valores, self.width, color='g')
        #self.line, = plt.plot(self.data)
        plt.ion() # animate

        N = 10
        self.xs = collections.deque(maxlen=N)
        self.ys = collections.deque(maxlen=N)
        self.xs.append(0)
        self.ys.append(0)

        self.ax = self.figure.add_subplot(111)
        self.ax.hold(False)
        self.ax.set_ylim([0, 360])

        self.canvas = FigureCanvas(self.figure)
        self.toolbar = NavigationToolbar(self.canvas, self)
        self.toolbar.hide()
        self.canvas.show()

        # set the layout
        self.layout = QVBoxLayout()
        self.layout.addWidget(self.toolbar)
        self.layout.addWidget(self.canvas)
        self.setLayout(self.layout)


    def add_sample(self, valores):
        self.valores = valores
        self.line = self.ax.bar(self.ordenadas, self.valores, self.width, color='g')
        self.canvas.draw()  # update the plot
开发者ID:cabama,项目名称:PatatitasRobot,代码行数:45,代码来源:modulo_barras.py

示例5: LMatplotlibWidget

# 需要导入模块: from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.NavigationToolbar2QTAgg import hide [as 别名]
class LMatplotlibWidget(LWidget):

    def __init__(self, parent=None):
        super(LMatplotlibWidget, self).__init__(parent)
        self.setName(WIDGET_NAME)
        self.buildUi()
        self.dataContainer = LMyDataContainer(self)
        self.actions = LMyActions(self.dataContainer,self)
        self.setDebugLevel(5)
        self.updateUi()

    @LInAndOut(DEBUG & WIDGETS)
    def buildUi(self):
        self.verticalLayout = QVBoxLayout(self)
        self.figure = Figure()
        self.canvas = Canvas(self.figure)	                # <-- figure required
        self.navigationToolbar = NavigationToolbar(self.canvas, self)
        self.verticalLayout.addWidget(self.canvas)
        self.verticalLayout.addWidget(self.navigationToolbar)

        #Canvas.setSizePolicy(self.canvas, QSizePolicy.Expanding, QSizePolicy.Expanding)
        #Canvas.updateGeometry(self.canvas)

    @LInAndOut(DEBUG & WIDGETS)
    def updateUi(self):
        left = self.dataContainer.leftMargin
        bottom = self.dataContainer.bottomMargin
        right = self.dataContainer.rightMargin
        top = self.dataContainer.topMargin
        wspace = self.dataContainer.verticalSeparation
        hspace = self.dataContainer.horizontalSeparation
        self.figure.subplots_adjust(left, bottom, right, top, wspace, hspace)

        if self.dataContainer.showNavigationToolbar:
            self.navigationToolbar.show()
        else:
            self.navigationToolbar.hide()

    #----------------------------------------------------------------------
    # Interface (set)

    @LInAndOut(DEBUG & WIDGETS)
    def setOptions(self, options):
        super(LMatplotlibWidget, self).setOptions(options)
        if options.verboseLevel is not None:
            self.setVerboseLevel(options.verboseLevel)
        if options.navigationToolbar is not None:
            self.showNavigationToolbar(options.navigationToolbar)
        self.updateUi()

    @LInAndOut(DEBUG & WIDGETS)
    def setVerboseLevel(self, level):
        self.dataContainer.verboseLevel = level

    #----------------------------------------------------------------------
    # Interface (get)

    def getFigure(self):
        return self.figure

    #----------------------------------------------------------------------
    # Interface (misc)

    @LInAndOut(DEBUG & WIDGETS)
    def showNavigationToolbar(self, flag=True):
        self.dataContainer.showNavigationToolbar = flag
        self.updateUi()

    @LInAndOut(DEBUG & WIDGETS)
    def snapshot(self, fileName = None):
        if fileName is None:
            caption = "%s - Save File" % self.name
            filter = "PNG Image (*.png);;All files (*.*)"
            fileName = QFileDialog.getSaveFileName(self.parent(), caption=caption,filter=filter )
            fileName = "%s" % fileName
        if len(fileName) > 0:
            self.figure.savefig(fileName, facecolor='w', edgecolor='w', orientation='portrait', papertype=None, format=None, transparent=False, bbox_inches=None, pad_inches=0.1)

    @LInAndOut(DEBUG & WIDGETS)
    def draw(self):
        self.canvas.draw()
开发者ID:emayssat,项目名称:python-eggs,代码行数:83,代码来源:matplot.py

示例6: Window

# 需要导入模块: from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.NavigationToolbar2QTAgg import hide [as 别名]
class Window(QtGui.QWidget):
    def __init__(self, parent=None):
        super(Window, self).__init__(parent)

        self.setWindowTitle('OpenWave-2KE')
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap("openwave.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.setWindowIcon(icon)

        #Waveform area.
        self.figure = plt.figure()
        self.figure.set_facecolor('white')

        self.canvas = FigureCanvas(self.figure)
        self.canvas.setMinimumSize(800,  400)
        
        self.toolbar = NavigationToolbar(self.canvas, self)
        self.toolbar.hide()

        #Zoom In/out and Capture Buttons
        self.zoomBtn = QtGui.QPushButton('Zoom')
        self.zoomBtn.setFixedSize(100, 30)
        self.zoomBtn.clicked.connect(self.toolbar.zoom)

        self.panBtn = QtGui.QPushButton('Pan')
        self.panBtn.setFixedSize(100, 30)
        self.panBtn.clicked.connect(self.toolbar.pan)

        self.homeBtn = QtGui.QPushButton('Home')
        self.homeBtn.setFixedSize(100, 30)
        self.homeBtn.clicked.connect(self.toolbar.home)

        self.captureBtn = QtGui.QPushButton('Capture')
        self.captureBtn.setFixedSize(100, 50)
        self.captureBtn.clicked.connect(self.captureAction)
        if(portNum==-1):
            self.captureBtn.setEnabled(False)

        #Type: Raw Data/Image
        self.typeBtn = QtGui.QPushButton('Raw Data')
        self.typeBtn.setToolTip("Switch to get raw data or image from DSO.")
        self.typeBtn.setFixedSize(120, 50)
        self.typeFlag=True #Initial state -> Get raw data
        self.typeBtn.setCheckable(True)
        self.typeBtn.setChecked(True)
        self.typeBtn.clicked.connect(self.typeAction)
        
        #Channel Selection.
        self.ch1checkBox = QtGui.QCheckBox('CH1')
        self.ch1checkBox.setFixedSize(60, 30)
        self.ch2checkBox = QtGui.QCheckBox('CH2')
        self.ch2checkBox.setFixedSize(60, 30)
        if(dso.chnum==4):
            self.ch3checkBox = QtGui.QCheckBox('CH3')
            self.ch3checkBox.setFixedSize(60, 30)
            self.ch4checkBox = QtGui.QCheckBox('CH4')
            self.ch4checkBox.setFixedSize(60, 30)
        
        #Set channel selection layout.
        self.selectLayout = QtGui.QHBoxLayout()
        self.selectLayout.addWidget(self.ch1checkBox)
        self.selectLayout.addWidget(self.ch2checkBox)
        if(dso.chnum==4):
            self.selectLayout2 = QtGui.QHBoxLayout()
            self.selectLayout2.addWidget(self.ch3checkBox)
            self.selectLayout2.addWidget(self.ch4checkBox)

        self.typeLayout = QtGui.QHBoxLayout()
        self.typeLayout.addWidget(self.typeBtn)
        self.typeLayout.addLayout(self.selectLayout)
        if(dso.chnum==4):
            self.typeLayout.addLayout(self.selectLayout2)

        #Save/Load/Quit button
        self.saveBtn = QtGui.QPushButton('Save')
        self.saveBtn.setFixedSize(100, 50)
        self.saveMenu = QtGui.QMenu(self)
        self.csvAction = self.saveMenu.addAction("&As CSV File")
        self.pictAction = self.saveMenu.addAction("&As PNG File")
        self.saveBtn.setMenu(self.saveMenu)
        self.saveBtn.setToolTip("Save waveform to CSV file or PNG file.")
        self.connect(self.csvAction, QtCore.SIGNAL("triggered()"), self.saveCsvAction)
        self.connect(self.pictAction, QtCore.SIGNAL("triggered()"), self.savePngAction)

        self.loadBtn = QtGui.QPushButton('Load')
        self.loadBtn.setToolTip("Load CHx's raw data from file(*.csv, *.lsf).")
        self.loadBtn.setFixedSize(100, 50)
        self.loadBtn.clicked.connect(self.loadAction)

        self.quitBtn = QtGui.QPushButton('Quit')
        self.quitBtn.setFixedSize(100, 50)
        self.quitBtn.clicked.connect(self.quitAction)

        # set the layout
        self.waveLayout = QtGui.QHBoxLayout()
        self.waveLayout.addWidget(self.canvas)
        
        self.wave_box=QtGui.QVBoxLayout()
        self.wave_box.addLayout(self.waveLayout)
        
#.........这里部分代码省略.........
开发者ID:kaikaimeng,项目名称:OpenWave-2KE,代码行数:103,代码来源:OpenWave-2KE.py

示例7: Window

# 需要导入模块: from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.NavigationToolbar2QTAgg import hide [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.canvas.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Expanding)

        self.toolbar = NavigationToolbar(self.canvas, self)
        self.toolbar.hide()

        # Timestream info
        self.timestreamLabel = QtGui.QLabel('Time-stream root path:')
        self.timestreamText = QtGui.QLineEdit('')
        self.timestreamText.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed)

        self.timestreamDateLabel = QtGui.QLabel('Start date (yyyy_mm_dd_hh_mm_ss):')
        self.timestreamDateText = QtGui.QLineEdit('')
        self.timestreamDateText.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed)

        self.timestreamTimeLabel = QtGui.QLabel('Time interval (seconds):')
        self.timestreamTimeText = QtGui.QLineEdit('')
        self.timestreamTimeText.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed)

        self.initStreamTimeButton = QtGui.QPushButton('&Initialise timestream by time')
        self.initStreamTimeButton.clicked.connect(self.initialiseTimestreamByTime)

        self.initStreamFileButton = QtGui.QPushButton('&Initialise timestream by files')
        self.initStreamFileButton.clicked.connect(self.initialiseTimestreamByFiles)

        # Image loading and processing
        self.loadImageButton = QtGui.QPushButton('&Load (next) image')
        self.loadImageButton.clicked.connect(self.loadImage)

        self.rotateImageButton = QtGui.QPushButton('&Rotate 90-deg')
        self.rotateImageButton.clicked.connect(self.rotateImage90Degrees)

        self.slider = QtGui.QSlider(QtCore.Qt.Horizontal)
        self.slider.setFocusPolicy(QtCore.Qt.StrongFocus)
        self.slider.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed)
        self.slider.setTickPosition(QtGui.QSlider.TicksBothSides)
        self.slider.setMinimum(-16)
        self.slider.setMaximum(16)
        self.slider.setValue(0)
        self.slider.setTickInterval(4)
        self.slider.setSingleStep(1)
        self.slider.valueChanged.connect(self.rotateSmallAngle)

        self.applySmallRotationButton = QtGui.QPushButton('&Apply')
        self.applySmallRotationButton.clicked.connect(self.applySmallRotation)

        self.loadCamCalibButton = QtGui.QPushButton('Load &cam. param.')
        self.loadCamCalibButton.clicked.connect(self.loadCamCalib)

        self.colorcardRadioButton = QtGui.QRadioButton('Select color car&d')
        self.colorcardRadioButton.setChecked(False)
        self.colorcardRadioButton.clicked.connect(self.selectWhat)

        self.trayRadioButton = QtGui.QRadioButton('Select &tray')
        self.trayRadioButton.setChecked(False)
        self.trayRadioButton.clicked.connect(self.selectWhat)

        self.trayRoundCheckBox = QtGui.QCheckBox('Round')
        self.trayRoundCheckBox.setChecked(True)

        self.potRadioButton = QtGui.QRadioButton('Select &pot')
        self.potRadioButton.setChecked(False)
        self.potRadioButton.clicked.connect(self.selectWhat)

        self.zoomButton = QtGui.QPushButton('&Zoom')
        self.zoomButton.setCheckable(True)
        self.zoomButton.clicked.connect(self.zoom)

        self.panButton = QtGui.QPushButton('&Pan')
        self.panButton.setCheckable(True)
        self.panButton.clicked.connect(self.pan)

        self.homeButton = QtGui.QPushButton('&Home')
        self.homeButton.clicked.connect(self.home)

        self.correctColorButton = QtGui.QPushButton('Correct colo&r')
        self.correctColorButton.clicked.connect(self.correctColor)

        self.save2PipelineButton = QtGui.QPushButton('&Save as pipeline settings')
        self.save2PipelineButton.clicked.connect(self.savePipelineSettings)

        self.testPipelineButton = QtGui.QPushButton('Test &pipeline processing')
        self.testPipelineButton.clicked.connect(self.testPipeline)

        self.status = QtGui.QTextEdit('')
        self.status.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Expanding)
        self.mousePosition = QtGui.QLabel('')

        # set the layout
        layout = QtGui.QHBoxLayout()
        rightWidget = QtGui.QWidget()
        buttonlayout = QtGui.QVBoxLayout(rightWidget)
        buttonlayout.addWidget(self.timestreamLabel)
        buttonlayout.addWidget(self.timestreamText)
        buttonlayout.addWidget(self.timestreamDateLabel)
#.........这里部分代码省略.........
开发者ID:borevitzlab,项目名称:timestreamlib,代码行数:103,代码来源:selectColorbarTrayPot.py

示例8: rebuild_widget

# 需要导入模块: from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.NavigationToolbar2QTAgg import hide [as 别名]
    def rebuild_widget(self, number_of_plots, plot_stretching):

        self.__number_of_plots = number_of_plots
        self.__plot_stretching = plot_stretching

        ids = []
        if self.__top_vbox.count() < self.__number_of_plots:
            ids = range(self.__top_vbox.count(), self.__number_of_plots)

        for i in ids:

            label = QLabel()
            label.setFont(self.__font)
            label.setAlignment(Qt.AlignCenter)

            # Create the mpl Figure and FigCanvas objects. 
            # 5x4 inches, 100 dots-per-inch
            #
            #dpi = 100
            #self.fig = Figure((5.0, 4.0), dpi=self.dpi)
            fig = pyplot.figure()
            canvas = FigureCanvas(fig)
            canvas.setParent(self)
    
            # Since we have only one plot, we can use add_axes 
            # instead of add_subplot, but then the subplot
            # configuration tool in the navigation toolbar wouldn't
            # work.
            #
            axes = fig.add_subplot(111)
    
            # Create the navigation toolbar, tied to the canvas
            #
            mpl_toolbar = NavigationToolbar(canvas, self, False)
    
            if self.__show_toolbar:
                mpl_toolbar.show()
            else:
                mpl_toolbar.hide()

            # Other GUI controls
            #
    
            tmp_vbox = QVBoxLayout()
            tmp_vbox.addWidget(label)
            tmp_vbox.addWidget(canvas, 1)
            tmp_vbox.addWidget(mpl_toolbar)

            widget = QWidget()
            widget.setLayout(tmp_vbox)

            self.__plots.append((label, canvas, fig, axes, mpl_toolbar, widget))

            self.__plot_infos.append((self.PLOT_TYPE_NONE, '', None, {}))

            self.__top_vbox.addWidget(widget)

        for i in xrange(self.__number_of_plots):

            stretch = 0
            if plot_stretching != None:
                stretch = plot_stretching[i]
                self.__top_vbox.setStretch(i, stretch)
            else:
                self.__top_vbox.setStretch(i, 1)

            plot = self.__plots[i]
            label, canvas, fig, axes, mpl_toolbar, widget = plot
            widget.show()

        for i in xrange(self.__number_of_plots, self.__top_vbox.count()):

            plot = self.__plots[i]
            label, canvas, fig, axes, mpl_toolbar, widget = plot
            widget.hide()

        if self.__show_menu:
            menubar = QMenuBar()
            save_menu = menubar.addMenu("&Save")
    
            menu_items = []
            for i,plot_info in enumerate(self.__plot_infos):
                plot_caption = plot_info[1]
                menu_name = "Save &plot '%s' [%d]" % (plot_caption, i+1)
                if len(plot_caption) == 0:
                    menu_name = "Save &plot #%d" % (i+1)
                save_plot_action = self.__make_action(menu_name,
                                                     shortcut="Ctrl+P",
                                                     slot=functools.partial(self.on_save_plot, i))
                menu_items.append(save_plot_action)
            menu_items.append(None)
            save_all_action = self.__make_action("Save &all plots",
                shortcut="Ctrl+A", slot=self.on_save_all_plots)
            menu_items.append(save_all_action)
    
            self.__add_actions(save_menu, menu_items)
    
            self.layout().setMenuBar(menubar)
开发者ID:,项目名称:,代码行数:100,代码来源:

示例9: MplWidget

# 需要导入模块: from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.NavigationToolbar2QTAgg import hide [as 别名]
class MplWidget(QtGui.QWidget):
    """Widget defined in Qt Designer"""
    def __init__(self, tools, toolbar=True, menu=True, parent=None):
        # initialization of Qt MainWindow widget
        QtGui.QWidget.__init__(self, parent)
        # set the canvas to the Matplotlib widget
        self.canvas = MplCanvas()
        # create a vertical box layout
        self.layout = QtGui.QVBoxLayout()
        # add mpl widget to layout
        self.layout.addWidget(self.canvas)
        # reference to toolsFrame
        self.tool = tools

        if toolbar:
            # add navigation toolbar to layout
            self.toolbar = NavigationToolbar(self.canvas, self)
            self.layout.addWidget(self.toolbar)
            # enable hover event handling
            self.setAttribute(Qt.WA_Hover)
            # create and install event filter
            self.filter = Filter(self)
            self.installEventFilter(self.filter)
            # hide toolbar
            self.initComponents()
        else:
            self.toolbar = None

        # set the layout to th vertical box
        self.setLayout(self.layout)
        # active lines list
        self.lines = []
        # legend
        self.legend = None
        # autoscale
        self.canvas.ax.autoscale_view(True, True, True)

        if menu:
            # setup context menu
            self.setContextMenuPolicy(Qt.ActionsContextMenu)
            self.initActions()
            self.alwaysAutoScale.setChecked(True)

    #-------------- initialization ---------------#
    def initComponents(self):
        if self.toolbar is not None:
            self.toolbar.hide()
            self.newIcons()

    def initActions(self):
        # toolbar
        self.toggleLegendAction = QtGui.QAction(QtGui.QIcon(RES + ICONS + LEGEND), 'Toggle legend',
                                     self, triggered=self.toggleLegend)
        self.toggleLegendAction.setCheckable(True)
        if self.toolbar is not None:
            self.toolbar.addAction(self.toggleLegendAction)

        # context menu
        self.addAction(self.toggleLegendAction)
        self.addAction(QtGui.QAction(QtGui.QIcon(RES + ICONS + COPY),'Copy data to table',
                                     self, triggered=self.toTable))
        self.addAction(QtGui.QAction(QtGui.QIcon(RES + ICONS + GRAPH),'Plot data in tools',
                                     self, triggered=self.toGraphTool))
        self.addAction(QtGui.QAction(QtGui.QIcon(RES + ICONS + SCALE), 'Autoscale',
                                     self, triggered=self.updateScale))

        self.alwaysAutoScale = QtGui.QAction('Scale on update', self)
        self.alwaysAutoScale.setCheckable(True)

        self.selectLinesMenu = QtGui.QMenu()
        self.selectLines = (QtGui.QAction('Plots', self))
        self.selectLines.setMenu(self.selectLinesMenu)

        aSep = QtGui.QAction('', self)
        aSep.setSeparator(True)
        self.addAction(aSep)
        self.addAction(self.selectLines)
        self.addAction(self.alwaysAutoScale)

    def newIcons(self):
        for position in range(0, self.toolbar.layout().count()):
            widget = self.toolbar.layout().itemAt(position).widget()
            if isinstance(widget, QtGui.QToolButton):
                icon = QtGui.QIcon(RES + ICONS + TOOLBAR_ICONS[position])
                self.toolbar.layout().itemAt(position).widget().setIcon(icon)

        self.toolbar.setIconSize(QSize(ICO_GRAPH, ICO_GRAPH))

    def resetGraphicEffect(self):
        if self.graphicsEffect() is not None:
            self.graphicsEffect().setEnabled(False)

    #------------- plotting methods ---------------#

    ## Hides axes in widget.
    #  @param axes Widget axes form canvas.
    @staticmethod
    def hideAxes(axes):
        axes.get_xaxis().set_visible(False)
        axes.get_yaxis().set_visible(False)
#.........这里部分代码省略.........
开发者ID:Xifax,项目名称:muscale,代码行数:103,代码来源:graphWidget.py

示例10: Window

# 需要导入模块: from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.NavigationToolbar2QTAgg import hide [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.canvas.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Expanding)
         
        self.toolbar = NavigationToolbar(self.canvas, self)
        self.toolbar.hide()
 
        # Just some button 
        self.colorcardRadioButton = QtGui.QRadioButton('Select color car&d')
        self.colorcardRadioButton.setChecked(False)
        self.colorcardRadioButton.clicked.connect(self.selectWhat)
        
        self.trayRadioButton = QtGui.QRadioButton('Select &tray')
        self.trayRadioButton.setChecked(False)
        self.trayRadioButton.clicked.connect(self.selectWhat)

        self.potRadioButton = QtGui.QRadioButton('Select &pot')
        self.potRadioButton.setChecked(False)
        self.potRadioButton.clicked.connect(self.selectWhat)

        self.loadImageButton = QtGui.QPushButton('&Load image')
        self.loadImageButton.clicked.connect(self.loadImage)
 
        self.rotateImageButton = QtGui.QPushButton('&Rotate 90-deg')
        self.rotateImageButton.clicked.connect(self.rotateImage90Degrees)
 
        self.loadCamCalibButton = QtGui.QPushButton('Load &cam. param.')
        self.loadCamCalibButton.clicked.connect(self.loadCamCalib)
 
        self.saveGeometriesButton = QtGui.QPushButton('&Save selected geometries')
        self.saveGeometriesButton.clicked.connect(self.saveSelectedGeometries)
 
        self.saveTraysButton = QtGui.QPushButton('&Save selected tray images')
        self.saveTraysButton.clicked.connect(self.saveSelectedTrayImages)
 
        self.saveColorcadButton = QtGui.QPushButton('&Save sel. col. card images')
        self.saveColorcadButton.clicked.connect(self.saveSelectedColorcardImages)
 
        self.save2PipelineButton = QtGui.QPushButton('&Save as pipeline settings')
        self.save2PipelineButton.clicked.connect(self.savePipelineSettings)
 
        self.zoomButton = QtGui.QPushButton('&Zoom')
        self.zoomButton.setCheckable(True)
        self.zoomButton.clicked.connect(self.zoom)
         
        self.panButton = QtGui.QPushButton('&Pan')
        self.panButton.setCheckable(True)
        self.panButton.clicked.connect(self.pan)
         
        self.homeButton = QtGui.QPushButton('&Home')
        self.homeButton.clicked.connect(self.home)
        
        self.status = QtGui.QTextEdit('')
        self.status.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Expanding)
        self.mousePosition = QtGui.QLabel('')
 
        # set the layout
        layout = QtGui.QHBoxLayout()
        rightWidget = QtGui.QWidget()
        buttonlayout = QtGui.QVBoxLayout(rightWidget)
        buttonlayout.addWidget(self.loadImageButton)
        buttonlayout.addWidget(self.rotateImageButton)
        buttonlayout.addWidget(self.loadCamCalibButton)
        buttonlayout.addWidget(self.colorcardRadioButton)
        buttonlayout.addWidget(self.trayRadioButton)
        buttonlayout.addWidget(self.potRadioButton)
        buttonlayout.addWidget(self.zoomButton)
        buttonlayout.addWidget(self.panButton)
        buttonlayout.addWidget(self.homeButton)
        buttonlayout.addWidget(self.saveGeometriesButton)
        buttonlayout.addWidget(self.saveColorcadButton)
        buttonlayout.addWidget(self.saveTraysButton)
        buttonlayout.addWidget(self.save2PipelineButton)
        buttonlayout.addWidget(self.status)
        buttonlayout.addWidget(self.mousePosition)
        rightWidget.setMaximumWidth(200)
        leftLayout = QtGui.QVBoxLayout()
        leftLayout.addWidget(self.toolbar)
        leftLayout.addWidget(self.canvas)

        layout.addWidget(rightWidget)
        layout.addLayout(leftLayout)
        self.setLayout(layout)
 
        self.group = QtGui.QButtonGroup()
        self.group.addButton(self.colorcardRadioButton)
        self.group.addButton(self.trayRadioButton) 
        self.group.addButton(self.potRadioButton) 
        
        self.panMode = False
        self.zoomMode = False
        
        self.ax = None
        self.plotRect = None
        self.plotImg = None
        self.image = None
#.........这里部分代码省略.........
开发者ID:chuong,项目名称:traitcapture-bin,代码行数:103,代码来源:selectColorbarTrayPot.py

示例11: MatplotlibWidget

# 需要导入模块: from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.NavigationToolbar2QTAgg import hide [as 别名]

#.........这里部分代码省略.........
        selected_dates = self.dates[indices]
        selected_values = self.parameter["data"][indices]

        # compute simple stats on selected values 
        selected_values_mean = nanmean(selected_values)
        selected_value_max = np.nanmax(selected_values)
        selected_value_min = np.nanmin(selected_values)

        return selected_dates, selected_values, selected_values_mean, selected_value_max, selected_value_min

    def on_select_axes(self, xmin, xmax):
        """ A select handler for SpanSelector that updates axes with the new x and y limits selected by user """

        selected_dates, selected_values, selected_values_mean, selected_value_max, selected_value_min = self.on_select_helper(xmin, xmax)

        # plot the selected values and update plots limits and text
        self.axes.plot(selected_dates, selected_values, self.color_str)
        self.axes.set_xlim(selected_dates[0], selected_dates[-1])
        self.axes.set_ylim(selected_values.min(), selected_values.max())

        text = 'mean = %.2f\nmax = %.2f\nmin = %.2f' % (selected_values_mean, selected_value_max, selected_value_min)           
        self.axes_text.set_text(text)

        # draw the updated plot
        self.canvas.draw() 

    def toggle_selector(self, radio_button_label):
        """ 
        A toggle radio buttons for the matplotlib SpanSelector widget.
        """ 

        if radio_button_label == "Span On":
            self.span_selector.visible = True
            self.matplotlib_toolbar.hide()

        elif radio_button_label == "Span Off":
            self.span_selector.visible = False
            self.matplotlib_toolbar.show()         
            self.plot_watertxt_parameter(watertxt_data = self.watertxt_data, name = self.parameter["name"])

    def clear_watertxt_plot(self):
        """ Clear the plot axes """ 

        self.figure.clear()
        self.canvas.draw()

    def reset_watertxt_plot(self):
        """ Clear the plot axes """ 

        self.axes.clear()
        self.canvas.draw()
        self.axes.grid(True)

    #-------------------------------- WATER.txt Parameter Comparison Plot ------------------------------------        

    def setup_watertxtcmp_plot(self):
        """ Setup the watertxt plot """

        self.clear_watertxtcmp_plot()

        # set up axes and its properties
        self.axes1 = self.figure.add_subplot(211)
        self.axes2 = self.figure.add_subplot(212, sharex = self.axes1)

        self.axes1.grid(True)
        self.axes2.grid(True)
开发者ID:jlant-usgs,项目名称:waterapputils,代码行数:70,代码来源:matplotlibwidget.py


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