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


Python FigureCanvasQTAgg.setFixedHeight方法代码示例

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


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

示例1: Fitter_Control_Widget

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

    def __init__(self, parent_graph, **kwargs):
        """
        This widget is a control pannel for the fitter
        """
        _gui.QWidget.__init__(self) 
        _uic.loadUi(_os.path.join(_os.path.dirname(__file__),'Fitter.ui'), self)
        self.graph = parent_graph
        self.kwargs = kwargs
        self.fitTraces = dict()
        self._fitted_name_association = dict()

        self.prepareLatex()
        self.generateCtrls()

        
        #Build a quick function to remove an item by name from the signal list
        def removeItemByName(name):
            for i in range(self.signalSelect.count()):
                if self.signalSelect.itemText(i)==name:
                    self.signalSelect.removeItem(i)
        self.signalSelect.removeItemByName = removeItemByName
        
        self.graph.traceAdded[str].connect(lambda x: self.signalSelect.addItem(x))
        self.graph.traceRemoved[str].connect(lambda x: self.signalSelect.removeItemByName(x))

    def prepareLatex(self):
        # Get window background color
        bg = self.palette().window().color()
        cl = (bg.redF(), bg.greenF(), bg.blueF())

        #Get figure and make it the same color as background
        self.fig = _plt.figure()
        self.latexHolder = FigureCanvas(self.fig)
        self.latexHolder.setFixedHeight(60)
        self.matplotlib_container.addWidget(self.latexHolder)
        #self.fig = self.latexMPLholder.figure
        self.fig.set_edgecolor(cl)
        self.fig.set_facecolor(cl)

    def generateCtrls(self):
        
        #Fill in the signal select input
        items = list(self.graph)
        self.signalSelect.addItems(items)
        self.signalSelect.setCurrentIndex(len(items)-1)
        
        
        #Link fit buttons
        self.fitBtn.clicked.connect(self.fitData)
        self.guessBtn.clicked.connect(self.guessP)        
        
        #Fill the combobox for fit function
        self.fitFct = fit.getAllFitFct()
        self.fitFctSelect.addItems(list(self.fitFct.keys()))
        self.fitFctSelect.currentIndexChanged.connect(self.generateFitTable)
        self.fitFctSelect.setCurrentIndex(list(self.fitFct.keys()).index('Gaussian'))
        
        #Begin/Stop continuous timer
        self.timer = _core.QTimer(self)
        self.timer.timeout.connect(self.fitData)
        self.contFitActive = False
        self.start_stop_btn.clicked.connect(self.toogleContFit)        
        
        #Fill in the combobox for error method
        self.errorMethodSelect.addItems(fit.Generic_Fct.allowedErrorMethods) 
        self.errorMethodSelect.setCurrentIndex(fit.Generic_Fct.allowedErrorMethods.index('subtract'))
        
        #Link the output btns
        self.calcOutBtn.clicked.connect(lambda: self.generateOutputTable()) 
        self.exportOutputAllBtn.clicked.connect(lambda: self.exportOutputToClipboard(All=True))
        self.exportOutputValBtn.clicked.connect(lambda: self.exportOutputToClipboard(All=False))
        
        #Dynamically generate the fit variables table
        self.generateFitTable()
        
        
    def generateFitTable(self):
        """
        Delete the current table and regenerate a new one based on the current
        fonction variables.
        """
        #Fetch fct name and variables
        fctName = str(self.fitFctSelect.currentText())
        fctVars = self.fitFct[fctName].getParamList()
        
        #Update Latex
        self.generateLatex()
        
        #Set the size of the table
        self.fitVariableTable.setRowCount(len(fctVars))
        
        #Fill in the table
        self.fitVarInputs = dict()
        ri = 0
        for var in fctVars:
            #Set variable name in collumn 0
            self.fitVariableTable.setCellWidget(ri,0,_gui.QLabel(str(var)))
            
#.........这里部分代码省略.........
开发者ID:AlexBourassa,项目名称:A-Lab,代码行数:103,代码来源:Fitter.py

示例2: MiniMap

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setFixedHeight [as 别名]
class MiniMap(QtGui.QWidget):
    """Shows the entire signal and allows the user to navigate through it.

    Provides an scrollable selector over the entire signal.

    Attributes:
        xmin: Selector lower limit (measured in h-axis units).
        xmax: Selector upper limit (measured in h-axis units).
        step: Selector length (measured in h-axis units).
    """

    def __init__(self, parent, ax, record=None):
        super(MiniMap, self).__init__(parent)
        self.ax = ax

        self.xmin = 0.0
        self.xmax = 0.0
        self.step = 10.0
        self.xrange = np.array([])

        self.minimapFig = plt.figure()
        self.minimapFig.set_figheight(0.75)
        self.minimapFig.add_axes((0, 0, 1, 1))
        self.minimapCanvas = FigureCanvas(self.minimapFig)
        self.minimapCanvas.setFixedHeight(64)
        self.minimapSelector = self.minimapFig.axes[0].axvspan(0, self.step,
                                                               color='gray',
                                                               alpha=0.5,
                                                               animated=True)
        self.minimapSelection = self.minimapFig.axes[0].axvspan(0, self.step,
                                                                color='LightCoral',
                                                                alpha = 0.5,
                                                                animated=True)
        self.minimapSelection.set_visible(False)
        self.minimapBackground = []
        self.minimapSize = (self.minimapFig.bbox.width,
                            self.minimapFig.bbox.height)

        self.press_selector = None
        self.playback_marker = None
        self.minimapCanvas.mpl_connect('button_press_event', self.onpress)
        self.minimapCanvas.mpl_connect('button_release_event', self.onrelease)
        self.minimapCanvas.mpl_connect('motion_notify_event', self.onmove)

        # Animation related attrs.
        self.background = None
        self.animated = False

        # Set the layout
        self.layout = QtGui.QVBoxLayout(self)
        self.layout.addWidget(self.minimapCanvas)

        # Animation related attributes
        self.parentViewer = parent

        # Set Markers dict
        self.markers = {}

        self.record = None
        if record is not None:
            self.set_record(record)

    def set_record(self, record, step):
        self.record = record
        self.step = step
        self.xrange = np.linspace(0, len(self.record.signal) / self.record.fs,
                                  num=len(self.record.signal), endpoint=False)
        self.xmin = self.xrange[0]
        self.xmax = self.xrange[-1]
        self.markers = {}

        ax = self.minimapFig.axes[0]
        ax.lines = []
        formatter = FuncFormatter(lambda x, pos: str(datetime.timedelta(seconds=x)))
        ax.xaxis.set_major_formatter(formatter)
        ax.grid(True, which='both')
        # Set dataseries to plot
        xmin = self.xmin * self.record.fs
        xmax = self.xmax * self.record.fs
        pixel_width = np.ceil(self.minimapFig.get_figwidth() * self.minimapFig.get_dpi())
        x_data, y_data = plotting.reduce_data(self.xrange, self.record.signal, pixel_width, xmin, xmax)
        # self._plot_data.set_xdata(x_data)
        # self._plot_data.set_ydata(y_data)
        ax.plot(x_data, y_data, color='black', rasterized=True)
        ax.set_xlim(self.xmin, self.xmax)
        plotting.adjust_axes_height(ax)
        # Set the playback marker
        self.playback_marker = PlayBackMarker(self.minimapFig, self)
        self.playback_marker.markers[0].set_animated(True)
        # Draw canvas
        self.minimapCanvas.draw()
        self.minimapBackground = self.minimapCanvas.copy_from_bbox(self.minimapFig.bbox)
        self.draw_animate()

    def onpress(self, event):
        self.press_selector = event
        xdata = round(self.get_xdata(event), 2)
        xmin = round(xdata - (self.step / 2.0), 2)
        xmax = round(xdata + (self.step / 2.0), 2)
        self.parentViewer._set_animated(True)
#.........这里部分代码省略.........
开发者ID:cageo,项目名称:Romero-2016,代码行数:103,代码来源:svwidget.py


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