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


Python QwtPlot.setAxisScale方法代码示例

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


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

示例1: qwtchart

# 需要导入模块: from PyQt4.Qwt5 import QwtPlot [as 别名]
# 或者: from PyQt4.Qwt5.QwtPlot import setAxisScale [as 别名]
class qwtchart(chart):
    colours = {'red'    : Qt.red,
               'green'  : Qt.green,
               'blue'   : Qt.blue,
               'yellow' : Qt.yellow,
               'magenta': Qt.magenta,
               'black'  : Qt.black}
    styles = {'-' : Qt.SolidLine,
              '--': Qt.DashLine,
              ':' : Qt.DotLine,
              '-.': Qt.DashDotLine}

    def getPen(self, colour, style):
        return QPen(self.colours[colour], 1, self.styles[style])

    def __init__(self, spurset, fef, parent):
        chart.__init__(self, spurset, fef, parent)
        self.plot = QwtPlot(parent)

        self.plot.setAxisScale(xaxis, self.spurset.RFmin,
                               self.spurset.RFmax)
        self.plot.setAxisScale(yaxis, -self.spurset.dspan/2,
                               self.spurset.dspan/2)

        self.plot.setCanvasBackground(Qt.white)
        grid = QwtPlotGrid()
        grid.setMajPen(QPen(Qt.black, 1, Qt.DotLine))
        grid.attach(self.plot)

        self.plot.insertLegend(QwtLegend(self.parent), QwtPlot.ExternalLegend)

        # a picker to be used for the front-end filter parallelogram
        self.picker = QwtPlotPicker(xaxis, yaxis,
                                    QwtPicker.PointSelection,
                                    QwtPlotPicker.NoRubberBand,
                                    QwtPicker.AlwaysOff,
                                    self.plot.canvas())
        # gonna need this to implement ondrop()
        self._mouseRelease = self.picker.widgetMouseReleaseEvent
        self._picked_obj = None

        self.picker.connect(self.picker, SIGNAL('appended(const QPoint&)'),
                            self.onpick)
        self.picker.connect(self.picker, SIGNAL('moved(const QPoint&)'),
                            self.ondrag)
        # all about the monkey-patching
        self.picker.widgetMouseReleaseEvent = self.ondrop

    def redraw(self):
        xscale = self.plot.axisScaleDiv(xaxis)
        yscale = self.plot.axisScaleDiv(yaxis)
        #TODO check if it hurts to just set the scales every time, as in mpl
        if (xscale.lowerBound() != self.spurset.RFmin or
            xscale.upperBound() != self.spurset.RFmax):
            self.plot.setAxisScale(xaxis, self.spurset.RFmin,
                                   self.spurset.RFmax)
        if (yscale.lowerBound() != -self.spurset.dspan/2 or
            yscale.upperBound() != self.spurset.dspan/2):
            self.plot.setAxisScale(yaxis, -self.spurset.dspan/2,
                                   self.spurset.dspan/2)
        self.plot.replot()

    def mkline(self, xdata, ydata, style=('black','-'), title=''):
        line = QwtPlotCurve(title)
        if title is '':
            # don't display it in the legend
            # kind of ugly, that the title variable is doing double duty
            line.setItemAttribute(QwtPlotItem.Legend, False)
        pen = self.getPen(*style)
        line.setPen(pen)
        line.setRenderHint(QwtPlotItem.RenderAntialiased)
        line.setData(xdata, ydata)
        return line

    def add_line(self, line):
        line.attach(self.plot)

    def del_line(self, line):
        line.detach()

    def legend(self):
        return self.plot.legend()

    def _xval(self, pos):
        # from a QPoint referring to a pixel on the plot, find the x value
        return self.plot.invTransform(xaxis, pos.x())

    def _yval(self, pos):
        # from a QPoint referring to a pixel on the plot, find the y value
        return self.plot.invTransform(yaxis, pos.y())

    def onpick(self, pos):
        # for now, we only worry about picking the two vertical lines of the
        # front-end filter parallelogram. Other clicks are no-ops.
        if abs(pos.x() - self.plot.transform(xaxis, self.fef.start)) <= 10:
            # TODO check pos.y() as well
            self._picked_obj = self.fef.startline
            self.pick(self.fef.startline, self._xval(pos), self._yval(pos))
        elif abs(pos.x() - self.plot.transform(xaxis, self.fef.stop)) <= 10:
            self._picked_obj  = self.fef.stopline
#.........这里部分代码省略.........
开发者ID:patrickyeon,项目名称:spurdist,代码行数:103,代码来源:qwtchart.py

示例2: ImageControlDialog

# 需要导入模块: from PyQt4.Qwt5 import QwtPlot [as 别名]
# 或者: from PyQt4.Qwt5.QwtPlot import setAxisScale [as 别名]

#.........这里部分代码省略.........
            self._hist_bins_hires = hmin0 + (hmax0 - hmin0) * (numpy.arange(self.NumHistBinsHi) + 0.5) / float(
                self.NumHistBinsHi)
            self._hist_binsize_hires = (hmax0 - hmin0) / self.NumHistBins
        # if hist limits not specified, then compute lo-res histogram based on the hi-res one
        if hmin is None:
            hmin, hmax = hmin0, hmax0
            # downsample to low-res histogram
            self._hist = self._hist_hires.reshape((self.NumHistBins, self.NumHistBinsHi / self.NumHistBins)).sum(1)
        else:
            # zoomed-in low-res histogram
            # bracket limits at subset range
            hmin, hmax = max(hmin, dmin), min(hmax, dmax)
            if hmin >= hmax:
                hmax = hmin + 1
            dprint(1, "computing histogram for", self._subset.shape, self._subset.dtype, hmin, hmax)
            self._hist = measurements.histogram(subset, hmin, hmax, self.NumHistBins, labels=mask,
                                                index=None if mask is None else False)
        dprint(1, "histogram computed")
        # compute bins
        self._itf_bins = hmin + (hmax - hmin) * (numpy.arange(self.NumItfBins)) / (float(self.NumItfBins) - 1)
        self._hist_bins = hmin + (hmax - hmin) * (numpy.arange(self.NumHistBins) + 0.5) / float(self.NumHistBins)
        # histogram range and position of peak
        self._hist_range = hmin, hmax
        self._hist_min, self._hist_max, self._hist_imin, self._hist_imax = measurements.extrema(self._hist)
        self._hist_peak = self._hist_bins[self._hist_imax]
        # set controls accordingly
        if dmin >= dmax:
            dmax = dmin + 1
        zoom = math.log10((dmax - dmin) / (hmax - hmin))
        self._whistzoom.setValue(zoom)
        self._whistunzoom.setEnabled(zoom > 0)
        self._whistzoomout.setEnabled(zoom > 0)
        # reset scales
        self._histplot.setAxisScale(QwtPlot.xBottom, hmin, hmax)
        self._histplot.setAxisScale(QwtPlot.yRight, 0, 1 + self.ColorBarHeight)
        # update curves
        # call _setHistLogScale() (with current setting) to update axis scales and set data
        self._setHistLogScale(self._ylogscale, replot=False)
        # set plot lines
        self._line_0.line.setData([0, 0], [0, 1])
        self._line_0.marker.setValue(0, 0)
        self._line_maxbin.line.setData([self._hist_peak, self._hist_peak], [0, 1])
        self._line_maxbin.marker.setValue(self._hist_peak, 0)
        self._line_maxbin.setText(("max bin:" + DataValueFormat) % self._hist_peak)
        # set half-max line
        self._line_halfmax.line.setData(self._hist_range, [self._hist_max / 2, self._hist_max / 2])
        self._line_halfmax.marker.setValue(hmin, self._hist_max / 2)
        # update ITF
        self._updateITF()

    def _updateStats(self, subset, minmax):
        """Recomputes subset statistics."""
        if subset.size <= (2048 * 2048):
            self._showMeanStd(busy=False)
        else:
            self._wlab_stats.setText(
                ("min: %s  max: %s  np: %d" % (DataValueFormat, DataValueFormat, self._subset.size)) % minmax)
            self._wmore_stats.show()

    def _updateDataSubset(self, subset, minmax, desc, subset_type):
        """Called when the displayed data subset is changed. Updates the histogram."""
        self._subset = subset
        self._subset_range = minmax
        self._wlab_subset.setText("Subset: %s" % desc)
        self._hist = self._hist_hires = None
        self._wreset_full.setVisible(subset_type is not RenderControl.SUBSET_FULL)
开发者ID:ska-sa,项目名称:tigger,代码行数:70,代码来源:ControlDialog.py

示例3: Ui_MainWindow

# 需要导入模块: from PyQt4.Qwt5 import QwtPlot [as 别名]
# 或者: from PyQt4.Qwt5.QwtPlot import setAxisScale [as 别名]
class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName(_fromUtf8("MainWindow"))
        MainWindow.resize(847, 480)
        self.centralwidget = QtGui.QWidget(MainWindow)
        self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
        self.horizontalLayout_2 = QtGui.QHBoxLayout(self.centralwidget)
        self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2"))
        self.verticalLayout = QtGui.QVBoxLayout()
        self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
        
        #Tworzenie zakładek
        self.tabs = QtGui.QTabWidget(self.centralwidget)        
        
        #Główny wykre
        self.plot = QwtPlot(self.centralwidget)
        self.plot.setObjectName(_fromUtf8("plot"))
        self.plot.setAxisScale(self.plot.yLeft, -20, 80)
        self.plot.setAutoFillBackground(True)
        #self.plot.setPalette(Qt.Qt.black)
        self.plot.setCanvasBackground(Qt.Qt.black)
        
        self.grid = QwtPlotGrid()
        '''self.Yscale = QwtScaleDiv()
        self.Yscale.setInterval(10)
        self.Xscale = QwtScaleDiv()
        self.Xscale.setInterval(10)
        self.grid.setYDiv(self.YScale)
        self.grid.setXDiv(self.Xscale)'''
        self.grid.setMajPen(Qt.Qt.gray)
        self.grid.attach(self.plot)
        
        self.tabs.addTab(self.plot, "Spectrum")
       
        self.curve = QwtPlotCurve('')
        self.curve.setPen(Qt.Qt.yellow)
        self.curve.attach(self.plot)
        
        self.hold_curve = QwtPlotCurve('')
        self.hold_curve.setPen(Qt.Qt.red)
        
        self.peak_marker = QwtPlotMarker()
        self.symbol = QwtSymbol(QwtSymbol.DTriangle, QtGui.QBrush(Qt.Qt.red), QtGui.QPen(Qt.Qt.red), QtCore.QSize(10,10))
        self.peak_marker.setSymbol(self.symbol)
        self.peak_marker.setLabelAlignment(Qt.Qt.AlignTop)
        
        self.sybmol_2 = QwtSymbol(QwtSymbol.DTriangle, QtGui.QBrush(Qt.Qt.red), QtGui.QPen(Qt.Qt.white), QtCore.QSize(10,10))
        self.marker_1 = QwtPlotMarker()
        self.marker_1.setSymbol(self.sybmol_2)
        self.marker_1.setLabelAlignment(Qt.Qt.AlignTop)
        self.marker_2 = QwtPlotMarker()
        self.marker_2.setSymbol(self.sybmol_2)
        self.marker_2.setLabelAlignment(Qt.Qt.AlignTop)
        self.marker_3 = QwtPlotMarker()
        self.marker_3.setSymbol(self.sybmol_2)
        self.marker_3.setLabelAlignment(Qt.Qt.AlignTop)
        self.marker_4 = QwtPlotMarker()
        self.marker_4.setSymbol(self.sybmol_2)
        self.marker_4.setLabelAlignment(Qt.Qt.AlignTop)
        self.delta_marker = QwtPlotMarker()
        self.delta_marker.setSymbol(self.sybmol_2)
        self.delta_marker.setLabelAlignment(Qt.Qt.AlignTop)
        
        self.markers = [self.marker_1, self.marker_2, self.marker_3, self.marker_4]
        
        self.save_curve_1 = QwtPlotCurve('')
        self.save_curve_1.setPen(Qt.Qt.green)
        self.save_curve_2 = QwtPlotCurve('')
        self.save_curve_2.setPen(Qt.Qt.cyan)
        self.save_curve_3 = QwtPlotCurve('')
        self.save_curve_3.setPen(Qt.Qt.magenta)
        self.saved_curves = [self.save_curve_1, self.save_curve_2, self.save_curve_3]
        
        #Wykres waterfall
        '''self.plot_2 = QwtPlot(self.centralwidget)
        self.plot_2.setObjectName(_fromUtf8("plot_2"))
        
        self.waterfall = QwtPlotSpectrogram()
        self.waterfall.attach(self.plot_2)
        
        self.colorMap = QwtLinearColorMap(Qt.Qt.darkCyan, Qt.Qt.red)
        self.scaleColors(80)
        self.waterfall.setColorMap(self.colorMap)
        #self.waterfallData = QwtRasterData()
        #self.tabs.addTab(self.plot_2, "Waterfall")'''
        
        self.verticalLayout.addWidget(self.tabs)
        
        self.picker = QwtPlotPicker(QwtPlot.xBottom, 
                                    QwtPlot.yLeft, 
                                    QwtPicker.PointSelection | QwtPicker.DragSelection,
                                    QwtPlotPicker.CrossRubberBand,
                                    QwtPicker.AlwaysOn,
                                    self.plot.canvas())
        self.picker.setTrackerPen(Qt.Qt.white)
        self.picker.setRubberBandPen(Qt.Qt.gray)
        
        self.freqBox = QtGui.QGroupBox(self.centralwidget)
        self.freqBox.setObjectName(_fromUtf8("freqBox"))
        self.verticalLayout_3 = QtGui.QVBoxLayout(self.freqBox)
#.........这里部分代码省略.........
开发者ID:tapczan666,项目名称:GUI_Analyzer,代码行数:103,代码来源:gui_ui.py


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