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


Python FigureCanvasQTAgg.show方法代码示例

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


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

示例1: __init__

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import show [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()
开发者ID:jintaoluo,项目名称:MDSM,代码行数:37,代码来源:multi_pixel.py

示例2: GraphView

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import show [as 别名]
class GraphView(qg.QWidget):
    def __init__(self, name='Name', title='Title', graph_title='Graph Title', parent = None):
        super(GraphView, self).__init__(parent)

        self.name = name
        self.graph_title = graph_title

        self.dpi = 100
        self.fig = Figure((5.0, 3.0), dpi = self.dpi, facecolor = (1,1,1), edgecolor = (0,0,0))
        self.axes = self.fig.add_subplot(111)
        
        self.canvas = FigureCanvas(self.fig)
        self.canvas.setParent(self)
        self.toolbar = NavigationToolbar(self.canvas,self)
        self.layout = qg.QVBoxLayout()
        self.layout.addWidget(self.toolbar)
        self.layout.addWidget(self.canvas)
        self.layout.setStretchFactor(self.canvas, 1)
        self.setLayout(self.layout)
        self.canvas.show()

    def clear(self):
        self.axes.clear()
    def plot(self,*args,**kwargs):
        self.axes.plot(*args,**kwargs)
    def draw(self):
        self.canvas.draw()
    def add_patch(self,patch):
        self.axes.add_patch(patch)
    def scatter(self,*args,**kwargs):
        self.axes.scatter(*args,**kwargs)
    def text(self,*args,**kwargs):
        self.axes.text(*args,**kwargs)
开发者ID:jackcarter125,项目名称:popupcad,代码行数:35,代码来源:operationnetwork.py

示例3: LiveGraphQt4

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import show [as 别名]
class LiveGraphQt4(Backend):
    """Ultimately, this is a QWidget (as well as a FigureCanvasAgg, etc.)."""

    def show(self, delay=50):
        self.canvas = FigureCanvasQTAgg(self.figure)
        self.canvas.show()

        self.timer = QtCore.QTimer(self.canvas)
        self.timer.timeout.connect(self.run)

        super().show(delay)
开发者ID:azonalon,项目名称:pymeasure,代码行数:13,代码来源:liveplot.py

示例4: Grafica

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import show [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: __init__

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import show [as 别名]
class MatplotlibPlot:
    """ Class encapsulating an matplotlib plot"""
    def __init__(self, parent = None, dpi = 100, size = (5,4)):
        """ 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()

    def plotCurve(self, data, xAxisRange = None, yAxisRange = None, xLabel = "", yLabel = ""):
        """ Plot the data as a curve"""

        # clear the axes and redraw the plot anew
        self.figure.clear()
        self.axes = self.figure.add_subplot(111)        
        self.axes.grid(True)
        self.axes.plot(range(np.size(data)), data)

        if xAxisRange is not None:        
            self.xAxisRange = xAxisRange
            self.axes.xaxis.set_major_formatter(ticker.FuncFormatter(
                       lambda x, pos=None: '%.2f' % self.xAxisRange[x] if 0 <= x < len(xAxisRange) else ''))
            for tick in self.axes.xaxis.get_ticklabels():
                  tick.set_rotation(15)

        if yAxisRange is not None:        
            self.yAxisRange = yAxisRange
            self.axes.xaxis.set_major_formatter(ticker.FuncFormatter(
                       lambda x, pos=None: '%.1f' % self.yAxisRange[y] if 0 <= y < len(yAxisRange) else ''))
            for tick in self.axes.yaxis.get_ticklabels():
                  tick.set_rotation(15)

        self.axes.xaxis.set_label_text(xLabel)
        self.axes.yaxis.set_label_text(yLabel)
        self.canvas.draw()
开发者ID:jintaoluo,项目名称:MDSM,代码行数:43,代码来源:processFolding.py

示例6: PlotTab

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

#.........这里部分代码省略.........

	        # init variable as self so that can access from the plot clicked button,
	        # want to make sure we delete when the checkbox is unchecked
 	        self.x_pretty_time_epoch_type = QtGui.QComboBox()
	        for timetype in epoch2datetime.timetypes:
	            self.x_pretty_time_epoch_type.addItem(timetype)
	            # if the timetype shows up in the units of the variable, autoselect it
	            if re.search(timetype, self.dataset.variables[xvar].units):
	                i = self.x_pretty_time_epoch_type.findText(timetype)
	                self.x_pretty_time_epoch_type.setCurrentIndex(i)
	        since = QtGui.QLabel("since")
	        self.x_pretty_time_epoch_start = QtGui.QDateTimeEdit()
	        # search for the timestring in the units, should match something like 2015-03-20
	        tryparsetime = re.search("[0-9,:,/,-]+ [0-9,:,/,-]+", self.dataset.variables[xvar].units)
	        if tryparsetime: #otherwise user has to configure themselves
	            tryparsetime = dateutil.parser.parse(tryparsetime.group(0))
	            self.x_pretty_time_epoch_start.setDateTime(tryparsetime)

	        # put things in the container
	        container_layout.addWidget(self.x_pretty_time_epoch_type, 0, 0)
	        container_layout.addWidget(since, 0, 1)
	        container_layout.addWidget(self.x_pretty_time_epoch_start, 0, 2)

	        # add the container to the parent container
	        self.pretty_time_container_layout.addWidget(container, 1, 0, 1, 2)
	    else:
	        # all the stuff above (combobox since datetimedit) was put in one container
	        # fixed at (1, 0) in pretty_time_container_layout so get it and delete it if 
	        # the box was unchecked
	        container = self.pretty_time_container_layout.getItemAtPosition(1, 0).widget()
	        self.pretty_time_container_layout.removeWidget(container)
	        container.deleteLater()
	        self.x_pretty_time_epoch_type = None

	def delete_clicked(self):
	    #delete the tab when the delete button is clicked
	    self.delete_this_tab.emit()

	def importvar_clicked(self):
	    #TODO: how to pull a local variable from the scope of the console
	    #print self.window().console.kernel_manager.kernel.shell.__dict__
	    pass

	def plot_clicked(self):
	    xvar = self.x_config_var_select.currentText()
	    yvar = self.y_config_var_select.currentText()
	    self.fig = Figure(figsize=(5, 4), dpi=100)
	    axes = self.fig.add_subplot(111)
	    axes.hold(False)
	    x = self.dataset.variables[xvar][:]
	    y = self.dataset.variables[yvar][:]
	    if self.x_config_widget_layout.itemAtPosition(3, 0):
	        #flatten x
	        flattening = []
	        for widget in self.x_flatten:
	            dim = widget.currentText()
	            if dim == "all":
			flattening.append(slice(None))
	            else:
	                flattening.append(int(dim))
                x = x[flattening].flatten()
	    if re.search("time", xvar):
	        if self.x_pretty_time_checkbox.isChecked():
	            #if this is a time variable and the checkbox for pretty time is checked
	            # then we know we need to parse the x variable and turn it into a datetime
	            # object to pass to matplotlib
	            tmp_epochtypestr = self.x_pretty_time_epoch_type.currentText()
	            tmp_epochbegin = self.x_pretty_time_epoch_start.dateTime().toPyDateTime()
	            convertor = epoch2datetime.Epoch2Datetime(tmp_epochtypestr, tmp_epochbegin)
	            x = [convertor.int2datetime(tmp_epoch) for tmp_epoch in x]

	    if self.y_config_widget_layout.itemAtPosition(3, 0):
	        #flatten y
	        flattening = []
	        for widget in self.y_flatten:
	            dim = widget.currentText()
	            if dim == "all":
			flattening.append(slice(None))
	            else:
	                flattening.append(int(dim))
                y = y[flattening].flatten()
	    self.plotwidget = FigureCanvas(self.fig)
	    axes.plot(x, y)
	    axes.set_title(self.plot_title_edit.text())
	    axes.set_xlabel(self.x_config_axis_label_edit.text())
	    axes.set_ylabel(self.y_config_axis_label_edit.text())
	    self.fig.autofmt_xdate()
	    self.plotwidget.show()

	def dataset_imported(self, dataset):
	    self.dataset = dataset

	    # clear the comboboxes in case they are already populated
	    # ie. reimporting a dataset, also b/c this is called on new tab
	    self.x_config_var_select.clear()
	    self.y_config_var_select.clear()
	    self.plot_title_edit.setText(self.dataset.title)
	    for var in self.dataset.variables:
	        self.x_config_var_select.addItem(var)
	        self.y_config_var_select.addItem(var)
开发者ID:5tefan,项目名称:pyGOES-R,代码行数:104,代码来源:plot_get_data.py

示例7: BottleWindow

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import show [as 别名]
class BottleWindow(QtGui.QWidget):
    "Document window for displaying a particular bottle"

    def __init__(self, bottle):
        super(BottleWindow, self).__init__(None)
        self.ui = uic.loadUi(get_ui_file('bottle_window.ui'), self)
        self.ui.readings_view.setModel(BottleModel(DataAnalyzer(bottle, delta=True)))
        for col in range(self.ui.readings_view.model().columnCount()):
            self.ui.readings_view.resizeColumnToContents(col)
        self.exporter = BottleExporter(self)
        if matplotlib:
            self.figure = Figure(figsize=(5.0, 5.0), facecolor='w', edgecolor='w')
            self.canvas = FigureCanvas(self.figure)
            self.axes = self.figure.add_subplot(111)
            self.ui.splitter.addWidget(self.canvas)
            self.redraw_timer = QtCore.QTimer()
            self.redraw_timer.setInterval(200) # msecs
            self.redraw_timer.timeout.connect(self.redraw_timeout)
            self.ui.splitter.splitterMoved.connect(self.splitter_moved)
        self.refresh_edits()
        self.setWindowTitle('Bottle %s' % bottle.serial)
        self.ui.absolute_check.toggled.connect(self.absolute_toggled)
        self.ui.points_spin.valueChanged.connect(self.points_changed)

    @property
    def model(self):
        return self.ui.readings_view.model()

    @property
    def bottle(self):
        return self.model.analyzer.bottle

    def refresh_window(self):
        "Forces the list to be re-read from the data logger"
        self.model.beginResetModel()
        self.model.analyzer.refresh()
        self.refresh_edits()
        self.model.endResetModel()

    def refresh_edits(self):
        "Refresh all the edit controls from the bottle"
        bottle = self.model.analyzer.bottle
        self.ui.bottle_serial_edit.setText(bottle.serial)
        self.ui.bottle_id_edit.setText(str(bottle.id))
        self.ui.measurement_mode_edit.setText(bottle.mode_string)
        self.ui.bottle_volume_spin.setValue(bottle.bottle_volume)
        self.ui.sample_volume_spin.setValue(bottle.sample_volume)
        self.ui.dilution_spin.setValue(bottle.dilution)
        self.ui.start_timestamp_edit.setText(bottle.start.strftime('%c'))
        self.ui.finish_timestamp_edit.setText(bottle.finish.strftime('%c'))
        self.ui.measurement_complete_edit.setText(bottle.completed)
        self.ui.desired_values_edit.setText(str(bottle.expected_measurements))
        self.ui.actual_values_edit.setText(str(bottle.actual_measurements))
        self.ui.points_spin.setMaximum(
            max(1, bottle.actual_measurements - (
                1 if bottle.actual_measurements % 2 == 0 else 0)))
        self.ui.points_spin.setEnabled(bottle.actual_measurements > 1)
        self.ui.absolute_check.setEnabled(bottle.actual_measurements > 1)
        if bottle.actual_measurements > 1:
            self.canvas.show()
            self.invalidate_graph()
        else:
            self.canvas.hide()

    def export_file(self):
        "Export the readings to a user-specified filename"
        self.exporter.export_file()

    def absolute_toggled(self, checked):
        "Handler for the toggled signal of the absolute_check control"
        self.model.delta = not checked
        if matplotlib:
            self.invalidate_graph()

    def points_changed(self, value):
        "Handler for the valueChanged signal of the points_spin control"
        self.model.points = value
        if matplotlib:
            self.invalidate_graph()

    def splitter_moved(self, pos, index):
        "Handler for the moved signal of the splitter control"
        self.invalidate_graph()

    def invalidate_graph(self):
        "Invalidate the matplotlib graph on a timer"
        if self.redraw_timer.isActive():
            self.redraw_timer.stop()
        self.redraw_timer.start()

    def redraw_timeout(self):
        "Handler for the redraw_timer's timeout event"
        self.redraw_timer.stop()
        self.redraw_figure()

    def redraw_figure(self):
        "Called to redraw the channel image"
        # Configure the x and y axes appearance
        self.axes.clear()
        self.axes.set_frame_on(True)
#.........这里部分代码省略.........
开发者ID:waveform80,项目名称:oxitopped,代码行数:103,代码来源:bottle_window.py

示例8: PointsView

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import show [as 别名]
class PointsView(QtGui.QDialog, Ui_PointsView):
    """
    Window for exploring and delating points
    """
    def __init__(self, reac_data, parent=None):
        QtGui.QDialog.__init__(self, parent)
        self.setupUi(self)
        self.setWindowTitle("Points view")
        self.reac_data = deepcopy(reac_data)
        self.axes = None
        self.axes2 = None
        self.fig = Figure()
        self.canvas = FigureCanvas(self.fig)
        self.mpl_toolbar = NavigationToolbar(self.canvas, parent)
        self.verticalLayout_3.addWidget(self.canvas)
        self.verticalLayout_3.addWidget(self.mpl_toolbar)

        # SS init
        if self.reac_data.is_single():
            self.label.hide()
            self.label_2.hide()
            self.VarBox.hide()
            self.SetBox.hide()
            self.qbox_level3()
        # DS init
        else:
            self.qbox_level1()

        # make change
        self.VarBox.activated.connect(self.qbox_level1)
        self.SetBox.activated.connect(self.qbox_level2)
        self.RepBox.activated.connect(self.qbox_level3)
        self.DelBut.clicked.connect(self.delete_points)

    def select_rep(self):
        """
        Returns you rep which should be bold
        """
        sel_set = self.SetBox.currentIndex()
        varsub = self.VarBox.currentIndex() == 0
        return [sel_set if varsub else -2, sel_set if not varsub else -2]

    def draw_plots(self):
        """
        Draw or re-draw plots
        """
        self.fig.clear()
        if self.reac_data.is_single():
            self.axes = self.fig.add_subplot(111)
            # Graph plot
            reaction_plots.plot_singlegraph(self.reac_data, self.axes, 0, pick=self.RepBox.currentIndex())
            self.canvas.draw()
            self.canvas.show()

        else:
            self.axes = self.fig.add_subplot(121)
            self.axes2 = self.fig.add_subplot(122)

            picks = self.select_rep()
            reaction_plots.plot_singlegraph(self.reac_data.get_repres(True), self.axes, 0, pick=picks[0], alpha1=0.75)
            reaction_plots.plot_singlegraph(self.reac_data.get_repres(False), self.axes2, 0, pick=picks[1], alpha1=0.75)

            # enhance single point
            sub_group = True if self.VarBox.currentIndex() == 0 else False
            plot_obj = self.axes if sub_group else self.axes2
            dat_set = self.SetBox.currentIndex()
            dat_rep = self.RepBox.currentIndex()
            # plot if possible
            try:
                plot_obj.plot(self.reac_data.AllVar[sub_group][dat_set][dat_rep],
                              self.reac_data.AllRates[sub_group][dat_set][dat_rep], 'o', color='red')
            except IndexError:
                pass
            self.canvas.draw()
            self.canvas.show()

    def qbox_level1(self):
        """
        Display changes stage 1
        """
        idx = self.VarBox.currentIndex()
        idx = 0 if idx == -1 else idx
        self.VarBox.clear()
        self.VarBox.addItems([self.reac_data.nameA, self.reac_data.nameB])
        self.VarBox.setCurrentIndex(idx)
        self.qbox_level2()

    def qbox_level2(self):
        """
        Display changes stage 2
        """
        idx = self.SetBox.currentIndex()
        idx = 0 if idx == -1 else idx
        self.SetBox.clear()
        subs_sel = True if self.VarBox.currentIndex() == 0 else False
        self.SetBox.addItems(['Set {}'.format(i + 1) for i in range(len(self.reac_data.AllVar[subs_sel]))])
        self.SetBox.setCurrentIndex(idx if idx < len(self.SetBox) else 0)
        self.qbox_level3()

    def qbox_level3(self):
#.........这里部分代码省略.........
开发者ID:miha-skalic,项目名称:ITEKA,代码行数:103,代码来源:widget_windows.py

示例9: Plot

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import show [as 别名]
class Plot(Callback.Callbacks):

    def __init__(self, logger):
        Callback.Callbacks.__init__(self)

        self.logger = logger

        # For callbacks
        for name in ('close', ):
            self.enable_callback(name)

        self.fig = matplotlib.figure.Figure()
        self.ax = self.fig.add_subplot(111)
        self.ax.set_xlabel('X values')
        self.ax.set_ylabel('Y values')
        self.ax.set_title('')
        self.ax.grid(True)
        self.canvas = FigureCanvas(self.fig)

    def get_widget(self):
        return self.canvas
    
    def _sanity_check_window(self):
        pass

    def set_titles(self, xtitle=None, ytitle=None, title=None,
                   rtitle=None):
        self._sanity_check_window()
        if xtitle != None:
            self.ax.set_xlabel(xtitle)
        if ytitle != None:
            self.ax.set_ylabel(ytitle)
        if title != None:
            self.ax.set_title(title)
        if rtitle != None:
            pass

    def clear(self):
        self._sanity_check_window()
        self.logger.debug('clearing canvas...')
        self.ax.cla()

    def show(self):
        self._sanity_check_window()
        self.logger.debug('raising window...')
        self.canvas.show()

    def hide(self):
        self._sanity_check_window()
        self.logger.debug('hiding window...')
        pass

    def close(self):
        self.logger.debug('closing window....')
        self.canvas.destroy()

        self.make_callback('close')
        return False

    def _draw(self):
        self.fig.canvas.draw()

    def plot(self, xarr, yarr, xtitle=None, ytitle=None, title=None,
             rtitle=None, **kwdargs):
        self.set_titles(xtitle=xtitle, ytitle=ytitle, title=title,
                        rtitle=rtitle)
        self.ax.plot(xarr, yarr, **kwdargs)
        self.ax.grid(True)
        self._draw()
开发者ID:PaulPrice,项目名称:ginga,代码行数:71,代码来源:Plot.py

示例10: View

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


    def __init__(self, parent = None, width=5, height=4, dpi=80, filename = None, model = None,
                        plot_type = 'Image', trace_num = None, region = []):
        # plot paramters #                                        
        self.t_num = trace_num
        self.region = region

        # connect model signal #
        self.model = model
        self.model.dataChanged.connect(self.update_views)
        
        # create a dictionary of views 
        self.view_options = {'Image': self.view_image,
                             'TracePlot': self.view_trace,
                             'PSD': self.view_psd,
                             'Surface':self.view_surface}
        super(View,self).__init__(parent)
        
        # make the figure
        self.figure = Figure((width, height), dpi)
        fig_color = (1.0, 1.0, 1.0, 1.0)
        self.figure.set_facecolor(fig_color)
        # create the canvas
        self.canvas = Canvas(self.figure)
        self.canvas.setParent(self)
        
        # create the toolbar and tie it to the canvas
        self.toolbar = Toolbar(self.canvas, self)
        self.layout = QtGui.QVBoxLayout()
        self.layout.addWidget(self.canvas)
        self.setLayout(self.layout)
        if filename:
            self.setWindowTitle(plot_type+': '+filename) 

        if plot_type == 'Surface':
            self.axes = self.figure.gca(projection='3d')
        else:
            self.axes = self.figure.add_subplot(111)
            
        self.axes.hold(False)

        self.view_options[plot_type]()
        self.canvas.show()   

    def view_image(self):
        self.axes.imshow(self.model.get_agc_data(),cmap = cm.coolwarm)
        self.axes.set_xticklabels([])
        self.axes.set_yticklabels([])  
        self.axes.set_xticks([])
        self.axes.set_yticks([])        
        self.axes.set_xlabel('source channel')        
        self.axes.set_ylabel('time')        
            
        
    def view_trace(self):
        print self.t_num
        y = self.model.getTrace(self.t_num)
        x = np.arange(len(y))
        self.axes.fill(x,y,'r',linewidth = 0)
        self.axes.set_xlabel('time')        
        self.axes.set_ylabel('amplitude') 
        self.axes.set_xlim(0,len(x))   
        self.axes.grid(True)    
    
    def view_surface(self):
        
        #x = np.arange(self.model.getNTraces())
        #y = np.arange(self.model.getTLength())       
        y = np.arange(self.region[1]-self.region[0])
        x = np.arange(self.region[3]-self.region[2])       
        x, y = np.meshgrid(x, y)
        z = self.model.get_agc_data()
        z = z[self.region[0]:self.region[1], self.region[2]:self.region[3]]
        print self.model.getTLength()
        self.axes.plot_surface(x,y,z, rstride=1, cstride=1, cmap=cm.coolwarm,
                               linewidth=0, antialiased=False)

    def view_psd(self):
        y = self.model.get_psd_of_trace(self.t_num)
        x = np.arange(-len(y)/2,len(y)/2)
        print x.shape
        print y.shape
        self.axes.semilogy(x,y,'r', linewidth  = 1)
        self.axes.set_xlabel('frequency')        
        self.axes.set_ylabel('spectral density')        
        self.axes.set_xlim(-len(x)/2,len(x)/2)   
        self.axes.grid(True)            
       
   
    def update_views(self):
        print "updating views"
开发者ID:amine85,项目名称:seismic-data-processing,代码行数:95,代码来源:view.py

示例11: Window

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

#.........这里部分代码省略.........

        dataTF.addAction(tick)
        dataTF.addAction(oned)
        dataTF.addAction(threed)
        dataTF.addAction(sevend)

        OHLCI.addAction(tick1)
        OHLCI.addAction(onem)
        OHLCI.addAction(fivem)
        OHLCI.addAction(fifteenm)
        OHLCI.addAction(thirtymin)
        OHLCI.addAction(oneh)
        OHLCI.addAction(threeh)


        topIndicator.addAction(noner)
        topIndicator.addAction(rsi)
        topIndicator.addAction(macd)


        middleIndicator.addAction(noner)
        middleIndicator.addAction(ema)
        middleIndicator.addAction(sma)




#_________________________________________________________________________
#

#Canvas------------------

        self.canvas = FigureCanvas(f)
        self.canvas.show()
        self.show()








#_________________________________________________________________________
#(down starting from top, from left, continuing, how many rows it spas across)
        grid = QtGui.QGridLayout()

        grid.addWidget(self.canvas, 0, 0, 2, 4)




        self.setLayout(grid)
#_________________________________________________________________________




#_________________________________________________________________________
#Functions--------------------------------------------------------------


    def close_application(self):
        print("whooaaaa so custom!!!")
        sys.exit()
开发者ID:eddwinn,项目名称:Platformtrader3,代码行数:69,代码来源:main.py

示例12: mGraph

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

#.........这里部分代码省略.........
        self.twoWkButton.hide()
        self.allButton.hide()
        self.matframe.hide()
        self.matPlotInfo.hide()
        self.toolbarFrame.hide()

        layout = QtGui.QVBoxLayout()
        layout.addLayout(buttonLayout)
        layout.addLayout(buttonLayout2)
        layout.addLayout(buttonLayout3)
        layout.addWidget(self.matPlotInfo)
        layout.addWidget(self.matframe)
        layout.addWidget(self.toolbarFrame)

        self.setLayout(layout)

    def enableAutoScaling(self):
        self.timer.start(self.refreshRateSec * 1000)
        # self.canvas.mpl_disconnect(self.cid)
        # self.cid = self.canvas.mpl_connect('button_press_event', self.disableAutoScaling)
        self.home = True
        self.matPlotInfo.hide()
        # self.deviceThread = threading.Thread(target =
        # self.plot, args=[self.currTimeRange])
        # If the main thread stops, stop the child thread
        # self.deviceThread.daemon = True
        # Start the thread
        # self.deviceThread.start()

        self.plot(self.currTimeRange)

    def disableAutoScaling(self, event):
        self.home = False
        self.matPlotInfo.show()
        self.canvas.update()
        # plt.show()
        # print event.name
        # self.canvas.mpl_disconnect(self.cid)
        # self.cid = self.canvas.mpl_connect('button_press_event', self.enableAutoScaling)
        self.timer.stop()
        # self.zoom(self.toolbar)

    def togglePlot(self):

        if not self.hidden:
            self.canvas.hide()
            self.toolbar.hide()
            self.thrtysecButton.hide()
            self.twoMinButton.hide()
            self.fiveMinButton.hide()
            self.thrtyMinButton.hide()
            self.twoHrButton.hide()
            self.tenHrButton.hide()
            self.oneDayButton.hide()
            self.oneWkButton.hide()
            self.twoWkButton.hide()
            self.allButton.hide()
            self.matPlotInfo.hide()
            self.matframe.hide()
            self.toolbarFrame.hide()
            self.timer.stop()
            self.hideButton.setText("Show Plot")
            self.hidden = True

        elif self.hidden:
            self.canvas.show()
开发者ID:McDermott-Group,项目名称:servers,代码行数:70,代码来源:MGrapher.py

示例13: MainDialog

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import show [as 别名]
class MainDialog(QDialog, layout.Ui_Dialog):

    def __init__(self, parent=None):
        super(MainDialog, self).__init__(parent)
        self.setupUi(self)
        self.AIRFOIL_DATA = None

        # Generamos dos figuras, cada una luego asociada a un canvas, que a su vez tiene como padre una de las pestanias
        # self.tab -> contiene la pestania titulada "Diagrama P-S"
        # self.tab_2 -> contiene la pestania titulada "Diagrama T-S"
        self.fig1 = Figure(figsize=(4.8, 3.4), dpi=72, facecolor=(1, 1, 1), edgecolor=(0, 0, 0))
        self.axes1 = self.fig1.add_subplot(111)
        self.axes1.set_ylabel('Cl')
        self.axes1.set_xlabel('AoA')
        self.fig2 = Figure(figsize=(4.8, 3.4), dpi=72, facecolor=(1, 1, 1), edgecolor=(0, 0, 0))
        self.axes2 = self.fig2.add_subplot(111)
        self.axes2.set_ylabel('Cd')
        self.axes2.set_xlabel('Cl')
        # generate the canvas to display the plot
        self.canvas1 = FigureCanvas(self.fig1)
        self.canvas1.setParent(self.frame_ClAlpha)
        self.canvas1.show()
        self.canvas2 = FigureCanvas(self.fig2)
        self.canvas2.setParent(self.frame_CdCl)
        self.canvas2.show()
        #Ponemos el primer checkbox en "checked"
        self.checkBox_Re3.setCheckState(Qt.Checked)
        # Cargamos los numeros de Reynolds
        self.Reynolds = ['Re_3', 'Re_6', 'Re_9', 'Re_std']
        # Cargamos los parametros caracteristicos del perfil
        self.vHeader = ['CL_max', 'beta_max',
                    'CL_betamax', 'alpha_betamax', 'dbeta_dalpha', 'b_max',
                    'CD_min', 'CL_CD_max', 'cuspide', 'CM0']
        # Cargamos el formato en que se deben mostrar cada parametro caracteristico
        self.HeadersFormat = ['{:.2f}', '{:.1f}', '{:.2f}', '{:.1f}', '{:.3f}', '{:.1f}',
                              '{:.5f}', '{:.1f}', str, '{:.2}']
        self.tableDatos.setVerticalHeaderLabels(self.vHeader)
        self.tableDatos.setHorizontalHeaderLabels(self.Reynolds)


        self.connect(self.openButton, SIGNAL("clicked()"), self.Open)
        self.connect(self.okButton, SIGNAL("clicked()"), self, SLOT('accept()'))
        self.connect(self.cancelButton, SIGNAL("clicked()"), self, SLOT('reject()'))
        self.connect(self.checkBox_Re3, SIGNAL("toggled(bool)"), self.plotGraph)
        self.connect(self.checkBox_Re6, SIGNAL("toggled(bool)"), self.plotGraph)
        self.connect(self.checkBox_Re9, SIGNAL("toggled(bool)"), self.plotGraph)
        self.connect(self.checkBox_SR, SIGNAL("toggled(bool)"), self.plotGraph)

    def Open(self):
        dir = '.'
        fileAdress = QFileDialog.getOpenFileName(self,"Selecionar Perfil",dir,filter="Text File (*.txt)")
        self.AIRFOIL_DATA = profile.lectura_perfiles(fileAdress[0])
        #print self.AIRFOIL_DATA

        for j in range(len(self.Reynolds)):
            for i in range(len(self.vHeader)):
                if self.vHeader[i] in self.AIRFOIL_DATA[self.Reynolds[j]].keys():
                    item = QTableWidgetItem(self.HeadersFormat[i].format(self.AIRFOIL_DATA[self.Reynolds[j]][self.vHeader[i]]))
                    self.tableDatos.setItem(i, j, item)
        nombrePerfil = fileAdress[0].split('/')[-1].split('.')[0]
        #print nombrePerfil
        self.labelPerfil.setText('Datos Perfil:  NACA '+nombrePerfil)
        self.plotGraph()

    def plotGraph(self):
        self.axes1.clear()
        self.axes2.clear()

        if self.checkBox_Re3.isChecked():
            self.plotReynolds('Re_3', 'b')

        if self.checkBox_Re6.isChecked():
            self.plotReynolds('Re_6', 'r')

        if self.checkBox_Re9.isChecked():
            self.plotReynolds('Re_9', 'g')

        if self.checkBox_SR.isChecked():
            self.plotReynolds('Re_std', 'y')

        self.canvas1.draw()
        self.canvas2.draw()

    def plotReynolds(self, reynolds, color):
        x1 = [value[0] for value in self.AIRFOIL_DATA[reynolds]['AoA_Cl']]
        y1 = [value[1] for value in self.AIRFOIL_DATA[reynolds]['AoA_Cl']]
        x2 = [value[0] for value in self.AIRFOIL_DATA[reynolds]['Cl_Cd']]
        y2 = [value[1] for value in self.AIRFOIL_DATA[reynolds]['Cl_Cd']]
        self.axes1.plot(x1, y1, color)
        self.axes2.plot(x2, y2, color)
开发者ID:enritoomey,项目名称:Perfiles2D,代码行数:92,代码来源:perfiles2D.py

示例14: SelectZoneWidget

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

    _imageChanged = pyqtSignal(np.ndarray)
    _imageReset = pyqtSignal()
    _homographyChanged = pyqtSignal(list)

    def __init__(self, hWidget, parent=None):
        super(SelectZoneWidget, self).__init__(parent)
        self._hWidget = hWidget
        self._imageChanged.connect(self._hWidget.setImage)
        self._homographyChanged.connect(self._hWidget.setHomography)
        self._imageReset.connect(self._hWidget.reset)
        self._initUI()

    # Initialize the UI
    def _initUI(self):
        # Widget parameters
        self.setMinimumWidth(300)

        # Create the figure
        self._fig = Figure()

        # Canvas configuration
        self._canvas = FigureCanvas(self._fig)
        self._canvas.setParent(self)
        self._canvas.mpl_connect('button_press_event', self._onPick)

        # Plot configuration
        self._plt = self._fig.add_subplot(111)
        self._plt.xaxis.set_visible(False)
        self._plt.yaxis.set_visible(False)

        # Finalize figure
        self._fig.subplots_adjust(wspace=0, hspace=0)

        # Reset the variables
        self.reset()

        # Create the layout
        vbox = QtGui.QVBoxLayout()

        # Add Canvas to the layout
        vbox.addWidget(self._canvas)

        # Set the layout
        self.setLayout(vbox)

        zp = ZoomPan()
        figZoom = zp.zoom_factory(self._plt)
        figPan = zp.pan_factory(self._plt)


    # Reset the variables to original state
    def reset(self):
        self._canvas.hide()
        self._image = None
        self._points = []
        self._imageReset.emit()

    # Set an image to the widget
    def setImage(self, image):
        self.reset()
        self._image = image
        self._redraw()
        self._canvas.show()
        self._imageChanged.emit(image)

    # Get the image of the widget
    def getImage(self):
        pass

    # Redraw the image and points
    def _redraw(self):
        # Clear the canvas
        self._plt.clear()

        # Plot the image
        if self._image is not None:
            self._plt.autoscale(True)
            self._plt.imshow(self._image)
            self._plt.autoscale(False)

        # Plot the points
        if len(self._points) > 0:
            xs = [x for (x, _) in self._points]
            ys = [y for (_, y) in self._points]
            self._plt.plot(xs + [xs[0]], ys + [ys[0]], '-', color='red')
            self._plt.plot(xs + [xs[0]], ys + [ys[0]], 'o', color='blue')

        # Draw the canvas
        self._canvas.draw()

    # Handle click events
    def _onPick(self, event):

        if event.button == 3:
            self._redraw()
        elif event.button != 1:
            return

#.........这里部分代码省略.........
开发者ID:StreakyCobra,项目名称:imaxplore,代码行数:103,代码来源:SelectZoneWidget.py

示例15: GraphView

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import show [as 别名]
class GraphView(QtGui.QWidget):
    def __init__(self, image, aa, pymol, pmap, parent=None):
        super(GraphView, self).__init__(parent)
        self.aa = aa
        self.pymol = pymol
        self.dpi = 300
        self.pmap = pmap
        self.fig = Figure((4.5, 4.5), dpi=self.dpi)
        self.axes = self.fig.add_subplot(111)
        self.canvas = FigureCanvas(self.fig)
        self.canvas.setParent(self)
        self.canvas.mpl_connect('button_press_event', self._onpick)
        self.layout = QtGui.QVBoxLayout()
        self.layout.addWidget(self.canvas)
        self.layout.setStretchFactor(self.canvas, 1)
        self.setLayout(self.layout)
        self.dmap = self.cmap_discretize(cm.spectral, 10)
        self.image = image
        self.map = self.axes.imshow(self.image, interpolation='nearest', cmap=self.dmap, aspect='equal', origin='lower')
        self.canvas.show()
        self.set_parameters()

    def cmap_discretize(self, cmap, N):
        """Return a discrete colormap from the continuous colormap cmap.

            cmap: colormap instance, eg. cm.jet.
            N: number of colors.

        Example
            x = resize(arange(100), (5,100))
            djet = cmap_discretize(cm.jet, 5)
            imshow(x, cmap=djet)
        """
        if type(cmap) == str:
            cmap = cm.get_cmap(cmap)
        colors_i = np.concatenate((np.linspace(0, 1., N), (0., 0., 0., 0.)))
        colors_rgba = cmap(colors_i)
        indices = np.linspace(0, 1., N + 1)
        cdict = {}
        for ki, key in enumerate(('red', 'green', 'blue')):
            cdict[key] = [(indices[i], colors_rgba[i - 1, ki], colors_rgba[i, ki]) for i in xrange(N + 1)]
        # Return colormap object.
        return colors.LinearSegmentedColormap(cmap.name + "_%d" % N, cdict, 1024)

    def _get_clicked_residues(self, event):
        xmin, xmax = self.axes.get_xlim()
        ymin, ymax = self.axes.get_ylim()
        return(int(math.ceil(event.xdata - xmin))-1, int(math.ceil(event.ydata - ymin))-1)

    def _onpick(self, event):
        if self.pmap.use_ca:
            atom = 'CA'
        else:
            atom = 'CB'

        index1, index2 = self._get_clicked_residues(event)
        if self.image[index1][index2] > 0:
            self.pymol.select_aminoacids(self.aa[index1], self.aa[index2], atom, self.pmap.cutoff)

    def set_parameters(self):
        cbar_ax = self.fig.add_axes([0.12, 0.94, 0.75, 0.03])
        cbar_ax.xaxis.labelpad = 3.0
        cbar_ax.tick_params(length=2.0, direction='out', pad=0.0)
        cbar = self.fig.colorbar(self.map, cax=cbar_ax, orientation='horizontal', drawedges=False)
        cbar_ax.xaxis.set_ticks_position('top')
        cbar_ax.xaxis.set_label_position('bottom')
        cbar_ax.xaxis.set_label_text('Contact Counts')
        self.axes.tick_params(axis=u'both', which=u'both', length=0)
        self.axes.xaxis.set_ticks(range(0, len(self.aa), 1))
        self.axes.yaxis.set_ticks(range(0, len(self.aa), 1))
        self.axes.set_xticklabels(self.aa, rotation=90)
        self.axes.set_yticklabels(self.aa)
        self.fig.patch.set_facecolor((0.886, 0.886, 0.886))
        ticks_font = mpl.font_manager.FontProperties(family='times new roman', style='normal', size=12, weight='normal',
                                                     stretch='normal')
        labels = [self.axes.title, self.axes.xaxis.label, self.axes.yaxis.label, cbar.ax.xaxis.label]
        labels += self.axes.get_xticklabels() + self.axes.get_yticklabels() + cbar.ax.get_xticklabels()
        for item in labels:
            item.set_fontproperties(ticks_font)
            item.set_fontsize(4)

    def update_graph(self, image):
        self.axes.clear()
        self.image = image
        self.map = self.axes.imshow(self.image, interpolation='nearest', cmap=self.dmap, aspect='equal', origin='lower')
        self.set_parameters()
        self.canvas.draw()
开发者ID:emptyewer,项目名称:CMPyMOL,代码行数:89,代码来源:heatmap.py


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