Exemplo n.º 1
0
	def __init__(self, *args):
		Qwt.QwtPlotItem.__init__(self, *args)
		self.__attributes = HistogramItem.Auto
		self.__data = Qwt.QwtIntervalData()
		self.__color = Qt.QColor()
		self.__reference = 0.0
		self.setItemAttribute(Qwt.QwtPlotItem.AutoScale, True)
		self.setItemAttribute(Qwt.QwtPlotItem.Legend, True)
		self.setZ(20.0)
		
		self.cached_bar_width = 1
		self.canvas_height = 2
		self.canvas_width = 2
		self.need_transform = False
		self.fl = [0.]
		self.fh = [0.]
		self.y = array([0.])
		self.y0 = 0.
		self.i = [0]
  		self.transform_slope = 1.
		self.transform_origin = 0.
		
		self.pixmaps = [QtGui.QPixmap()]
  
		self.yMap = None
Exemplo n.º 2
0
    def __init__(self, *args):
        Qwt.QwtPlotItem.__init__(self, *args)
        self.__attributes = HistogramItem.Auto
        self.__data = Qwt.QwtIntervalData()
        self.__color = Qt.QColor()
        self.__reference = 0.0
        self.setItemAttribute(Qwt.QwtPlotItem.AutoScale, True)
        self.setItemAttribute(Qwt.QwtPlotItem.Legend, True)
        self.setZ(20.0)

        self.cached_bar_width = 1
        self.canvas_height = 2
        self.canvas_width = 2
        self.need_transform = False
        self.fl = [0.]
        self.fh = [0.]
        self.fc = ["0"]  # center frequencies
        self.y = array([0.])
        self.y0 = 0.
        self.i = [0]
        self.transform_slope = 1.
        self.transform_origin = 0.

        self.pixmaps = [QtGui.QPixmap()]
        self.maxLabelPixHWidth = 0
        self.maxLabelPixVWidth = 0
        self.pixHWidths = 0
        self.pixVWidths = 0
        self.pixHHeights = 0
        self.pixVHeights = 0
        self.Hpixmaps = [[QtGui.QPixmap(), QtGui.QPixmap()]]
        self.Vpixmaps = [[QtGui.QPixmap(), QtGui.QPixmap()]]

        self.yMap = Qwt.QwtScaleMap()
Exemplo n.º 3
0
        def plot_spectrum(self):
            ''' Plot the histogram of the spectrum '''
            #self.__spectrum.set_demo_mode(True)

            #print self.__spectrum
            #logger.debug("{0:s}.plot_spectrum():".format(self.__class__.__name__))

            xarr = []
            yarr = []
            ordvals = self.__spectrum.get_spectrum_ord_values()
            x = 0
            pos = -0.25
            width = 0.5
            numValues = len(self.__spectrum)
            intervals = []
            values = Qwt.QwtArrayDouble(numValues)
            for (mass, p) in ordvals:
                # Lower limit for pressure set in HistogramItem.baseline()
                p = self.__barCurve.baseline(
                ) if p < self.__barCurve.baseline() else p
                xarr.append(x)
                yarr.append(p)
                intervals.append(Qwt.QwtDoubleInterval(pos, pos + width))
                values[x] = p
                pos += (width + 0.5)
                x += 1

            self.__barCurve.setData(Qwt.QwtIntervalData(intervals, values))

            self.clear_zoom_stack()
Exemplo n.º 4
0
 def __init__(self, *args):
     Qwt.QwtPlotItem.__init__(self, *args)
     self.__attributes = HistogramItem.Auto
     self.__data = Qwt.QwtIntervalData()
     self.__color = QColor()
     self.__reference = 0.0
     self.setItemAttribute(Qwt.QwtPlotItem.AutoScale, True)
     self.setItemAttribute(Qwt.QwtPlotItem.Legend, True)
     self.setZ(20.0)
Exemplo n.º 5
0
    def __init__(self, *args):
        Qwt.QwtPlotItem.__init__(self, *args)
        self.__attributes = HistogramItem.Auto
        self.__data = Qwt.QwtIntervalData()
        self.__color = QColor()
        self.__reference = 0.0
        self.setItemAttribute(Qwt.QwtPlotItem.AutoScale, True)
        self.setItemAttribute(Qwt.QwtPlotItem.Legend, True)
        self.setZ(20.0)

        self.to_long = lambda x: x
        architecture = platform.architecture()
        if architecture[0].startswith(
                '64') and architecture[1].lower().startswith('windows'):
            self.to_long = lambda x: long(x)
Exemplo n.º 6
0
    def addHistPlotData(self, _plotName, _values, _intervals):
        # print 'addHistPlotData'
        # print '_values=',_values
        # print '_intervals=',_intervals
        # self.plotData[_plotName]=[array([],dtype=double),array([],dtype=double),False]

        self.plotData[str(_plotName)] = [_intervals, _values, False, HISTOGRAM]

        intervals = []
        valLength = len(_values)
        values = Qwt.QwtArrayDouble(valLength)
        for i in range(valLength):
            #width = _intervals[i+1]-_intervals[i]+2
            intervals.append(
                Qwt.QwtDoubleInterval(_intervals[i], _intervals[i + 1]))
            #numpy automcatically adds extra element for edge
            values[i] = _values[i]

        self.plotHistData[_plotName].setData(
            Qwt.QwtIntervalData(intervals, values))
Exemplo n.º 7
0
def make():
    demo = Qwt.QwtPlot()
    demo.setCanvasBackground(Qt.Qt.white)
    demo.setTitle("Histogram")

    grid = Qwt.QwtPlotGrid()
    grid.enableXMin(True)
    grid.enableYMin(True)
    grid.setMajPen(Qt.QPen(Qt.Qt.black, 0, Qt.Qt.DotLine))
    grid.setMinPen(Qt.QPen(Qt.Qt.gray, 0, Qt.Qt.DotLine))

    grid.attach(demo)

    histogram = HistogramItem()
    histogram.setColor(Qt.Qt.darkCyan)

    numValues = 20
    intervals = []
    values = Qwt.QwtArrayDouble(numValues)

    pos = 0.0
    for i in range(numValues):
        width = 5 + random.randint(0, 4)
        value = random.randint(0, 99)
        intervals.append(Qwt.QwtDoubleInterval(pos, pos + width))
        values[i] = value
        pos += width

    histogram.setData(Qwt.QwtIntervalData(intervals, values))
    histogram.attach(demo)

    demo.setAxisScale(Qwt.QwtPlot.yLeft, 0.0, 100.0)
    demo.setAxisScale(Qwt.QwtPlot.xBottom, 0.0, pos)
    demo.replot()

    demo.resize(600, 400)
    demo.show()

    return demo