Esempio n. 1
0
    def __init__(self, parent=None, title=None):
        super(ErrorBarPlot, self).__init__("Errorbar Demonstation")
        self.setCanvasBackground(Qt.white)
        self.plotLayout().setAlignCanvasToScales(True)
        grid = QwtPlotGrid()
        grid.attach(self)
        grid.setPen(QPen(Qt.black, 0, Qt.DotLine))

        # calculate data and errors for a curve with error bars
        x = np.arange(0, 10.1, 0.5, float)
        y = np.sin(x)
        dy = 0.2 * abs(y)
        # dy = (0.15 * abs(y), 0.25 * abs(y)) # uncomment for asymmetric error bars
        dx = 0.2  # all error bars the same size
        errorOnTop = False  # uncomment to draw the curve on top of the error bars
        # errorOnTop = True # uncomment to draw the error bars on top of the curve
        symbol = QwtSymbol(
            QwtSymbol.Ellipse, QBrush(Qt.red), QPen(Qt.black, 2), QSize(9, 9)
        )
        curve = ErrorBarPlotCurve(
            x=x,
            y=y,
            dx=dx,
            dy=dy,
            curvePen=QPen(Qt.black, 2),
            curveSymbol=symbol,
            errorPen=QPen(Qt.blue, 2),
            errorCap=10,
            errorOnTop=errorOnTop,
        )
        curve.attach(self)
Esempio n. 2
0
 def __init__(self, *args):
     QwtPlot.__init__(self, *args)
     self.setTitle('Cartesian Coordinate System Demo')
     # create a plot with a white canvas
     self.setCanvasBackground(Qt.white)
     # set plot layout
     self.plotLayout().setCanvasMargin(0)
     self.plotLayout().setAlignCanvasToScales(True)
     # attach a grid
     grid = QwtPlotGrid()
     grid.attach(self)
     grid.setPen(QPen(Qt.black, 0, Qt.DotLine))
     # attach a x-axis
     xaxis = CartesianAxis(QwtPlot.xBottom, QwtPlot.yLeft)
     xaxis.attach(self)
     self.enableAxis(QwtPlot.xBottom, False)
     # attach a y-axis
     yaxis = CartesianAxis(QwtPlot.yLeft, QwtPlot.xBottom)
     yaxis.attach(self)
     self.enableAxis(QwtPlot.yLeft, False)
     # calculate 3 NumPy arrays
     x = np.arange(-2*np.pi, 2*np.pi, 0.01)
     y = np.pi*np.sin(x)
     z = 4*np.pi*np.cos(x)*np.cos(x)*np.sin(x)
     # attach a curve
     curve = QwtPlotCurve('y = pi*sin(x)')
     curve.attach(self)
     curve.setPen(QPen(Qt.green, 2))
     curve.setData(x, y)
     # attach another curve
     curve = QwtPlotCurve('y = 4*pi*sin(x)*cos(x)**2')
     curve.attach(self)
     curve.setPen(QPen(Qt.black, 2))
     curve.setData(x, z)
     self.replot()
Esempio n. 3
0
 def __init__(self, N):
     QwtPlot.__init__(self)
     self.setTitle('X-Y Signals')
     grid = QwtPlotGrid()
     pen = QPen(Qt.black, 0, Qt.DashDotLine)
     grid.setPen(pen)
     grid.attach(self)
Esempio n. 4
0
 def __init__(self, *args):
     QwtPlot.__init__(self, *args)
     self.setTitle("Cartesian Coordinate System Demo")
     # create a plot with a white canvas
     self.setCanvasBackground(Qt.white)
     # set plot layout
     self.plotLayout().setCanvasMargin(0)
     self.plotLayout().setAlignCanvasToScales(True)
     # attach a grid
     grid = QwtPlotGrid()
     grid.attach(self)
     grid.setPen(QPen(Qt.black, 0, Qt.DotLine))
     # attach a x-axis
     xaxis = CartesianAxis(QwtPlot.xBottom, QwtPlot.yLeft)
     xaxis.attach(self)
     self.enableAxis(QwtPlot.xBottom, False)
     # attach a y-axis
     yaxis = CartesianAxis(QwtPlot.yLeft, QwtPlot.xBottom)
     yaxis.attach(self)
     self.enableAxis(QwtPlot.yLeft, False)
     # calculate 3 NumPy arrays
     x = np.arange(-2 * np.pi, 2 * np.pi, 0.01)
     y = np.pi * np.sin(x)
     z = 4 * np.pi * np.cos(x) * np.cos(x) * np.sin(x)
     # attach a curve
     curve = QwtPlotCurve("y = pi*sin(x)")
     curve.attach(self)
     curve.setPen(QPen(Qt.green, 2))
     curve.setData(x, y)
     # attach another curve
     curve = QwtPlotCurve("y = 4*pi*sin(x)*cos(x)**2")
     curve.attach(self)
     curve.setPen(QPen(Qt.black, 2))
     curve.setData(x, z)
     self.replot()
Esempio n. 5
0
    def __init__(self, *args):
        QwtPlot.__init__(self, *args)

        self.setCanvasBackground(Qt.white)
        curva = QwtPlotCurve('Altitud')
        self.phase=0
        ##################################################
        # Initialize data
        self.x = [0]
        self.y = [0]
        # Title of the graph
        self.g1title = "Altitude= " + str(self.x[0])
        self.insertLegend(QwtLegend(), QwtPlot.BottomLegend);
        self.curveR = QwtPlotCurve("Altitude")
        self.curveR.attach(self)
        self.curveR.setPen(QPen(Qt.blue))
        self.setAxisTitle(QwtPlot.xBottom, "Time (seconds)")
        self.setAxisTitle(QwtPlot.yLeft, "Altitude(m)")
        self.setAxisScale(QwtPlot.xBottom, 0.0, 20)
        self.setAxisScale(QwtPlot.yLeft, 0.0, 20)
        self.pal = QPalette()  #####palette for background
        self.pal.setColor(QPalette.Text, Qt.white)
        self.pal.setColor(QPalette.Foreground, Qt.white)
        self.setPalette(self.pal)
        self.counter=0 ###counter for actualize data, is the same for all of the graphs/data
        grid = QwtPlotGrid()
        grid.attach(self)
        grid.setPen(QPen(Qt.black, 0, Qt.DotLine))
Esempio n. 6
0
def make():
    # create a plot with a white canvas
    demo = QwtPlot(QwtText("Errorbar Demonstation"))
    demo.setCanvasBackground(Qt.white)
    demo.plotLayout().setAlignCanvasToScales(True)

    grid = QwtPlotGrid()
    grid.attach(demo)
    grid.setPen(QPen(Qt.black, 0, Qt.DotLine))

    # calculate data and errors for a curve with error bars
    x = np.arange(0, 10.1, 0.5, np.float)
    y = np.sin(x)
    dy = 0.2 * abs(y)
    # dy = (0.15 * abs(y), 0.25 * abs(y)) # uncomment for asymmetric error bars
    dx = 0.2  # all error bars the same size
    errorOnTop = False  # uncomment to draw the curve on top of the error bars
    # errorOnTop = True # uncomment to draw the error bars on top of the curve
    curve = ErrorBarPlotCurve(
        x=x,
        y=y,
        dx=dx,
        dy=dy,
        curvePen=QPen(Qt.black, 2),
        curveSymbol=QwtSymbol(QwtSymbol.Ellipse, QBrush(Qt.red),
                              QPen(Qt.black, 2), QSize(9, 9)),
        errorPen=QPen(Qt.blue, 2),
        errorCap=10,
        errorOnTop=errorOnTop,
    )
    curve.attach(demo)
    demo.resize(640, 480)
    demo.show()
    return demo
Esempio n. 7
0
 def __init__(self, N):
     QwtPlot.__init__(self)
     self.setTitle('Time signals')
     self.setCanvasBackground(QBrush(QColor(COL, COL, COL)))
     grid = QwtPlotGrid()
     pen = QPen(Qt.black, 0, Qt.DashDotLine)
     grid.setPen(pen)
     grid.attach(self)
Esempio n. 8
0
    def __init__(self, *args):
        QwtPlot.__init__(self, *args)
	# make a QwtPlot widget
        self.plotLayout().setCanvasMargin(0)
        self.plotLayout().setAlignCanvasToScales(1)
        self.setTitle('QwtImagePlot: (un)zoom & (un)hide')
	# set axis titles
        self.setAxisTitle(QwtPlot.xBottom, 'time (s)')
        self.setAxisTitle(QwtPlot.yLeft, 'frequency (Hz)')
	# insert a few curves
        self.cSin = QwtPlotCurve('y = pi*sin(x)')
        self.cCos = QwtPlotCurve('y = 4*pi*sin(x)*cos(x)**2')
        self.cSin.attach(self)
        self.cCos.attach(self)
	# set curve styles
        self.cSin.setPen(QPen(Qt.green, 2))
        self.cCos.setPen(QPen(Qt.black, 2))
        self.xzoom_loc = None
        self.yzoom_loc = None
        self.xpos = None
        self.ypos = None

	# attach a grid
        grid = QwtPlotGrid()
        grid.attach(self)
        grid.setPen(Qt.black, 0, Qt.DotLine)

        # create zoom curve
        self.zoom_outline = QwtPlotCurve()
        self.zoom_outline.setStyle(QwtPlotCurve.Lines) 

        # create and initialize an image display
        self.plotImage = QwtPlotImage(self)
        self.plotImage.attach(self)
        self.gain = 2.0
        self.updateDisplay()

        self.zoomStack = []

        self.spy = Spy(self.canvas())
        self.prev_xpos = None
        self.prev_ypos = None

#       self.connect(self, Qt.SIGNAL("legendClicked(QwtPlotItem*)"),
#                    self.toggleVisibility)

        self.spy.MouseMove.connect(self.onmouseMoveEvent)
        self.spy.MousePress.connect(self.onmousePressEvent)
        self.spy.MouseRelease.connect(self.onmouseReleaseEvent)
def main(args):
    app = QApplication(args)
    demo = QwtPlot()
    grid = QwtPlotGrid()
    grid.attach(demo)
    grid.setPen(QPen(Qt.black, 0, Qt.DotLine))
    grid.enableX(True)
    grid.enableY(True)
    complex_divider = 50.0

    myXScale = ComplexScaleDraw(start_value=0.0, end_value=complex_divider)
    #print('myXScale', myXScale)
    demo.setAxisScaleDraw(QwtPlot.xBottom, myXScale)

    m = QwtPlotMarker()
    m.attach(demo)
    m.setValue(complex_divider, 0.0)
    m.setLineStyle(QwtPlotMarker.VLine)
    m.setLabelAlignment(Qt.AlignRight | Qt.AlignBottom)
    m.setLinePen(QPen(Qt.black, 2, Qt.SolidLine))

    vector_array = numpy.zeros((100, ), numpy.float32)
    for i in range(100):
        vector_array[i] = i

    curve = QwtPlotCurve('example data')
    curve.attach(demo)
    x_array = numpy.zeros(100, numpy.float32)
    y_array = numpy.zeros(100, numpy.float32)
    for i in range(100):
        x_array[i] = 1.0 * i
        y_array[i] = 2.0 * i
    curve.setSamples(x_array, y_array)

    demo.resize(600, 400)
    demo.replot()
    demo.show()
    #   app.setMainWidget(demo)
    app.exec_()
Esempio n. 10
0
def make():
    # create a plot with a white canvas
    demo = QwtPlot(QwtText("Errorbar Demonstation"))
    demo.setCanvasBackground(Qt.white)
    demo.plotLayout().setAlignCanvasToScales(True)

    grid = QwtPlotGrid()
    grid.attach(demo)
    grid.setPen(QPen(Qt.black, 0, Qt.DotLine))
    
    # calculate data and errors for a curve with error bars
    x = np.arange(0, 10.1, 0.5, np.float)
    y = np.sin(x)
    dy = 0.2 * abs(y)
    # dy = (0.15 * abs(y), 0.25 * abs(y)) # uncomment for asymmetric error bars
    dx = 0.2 # all error bars the same size
    errorOnTop = False # uncomment to draw the curve on top of the error bars
    # errorOnTop = True # uncomment to draw the error bars on top of the curve
    curve = ErrorBarPlotCurve(
        x = x,
        y = y,
        dx = dx,
        dy = dy,
        curvePen = QPen(Qt.black, 2),
        curveSymbol = QwtSymbol(QwtSymbol.Ellipse,
                                    QBrush(Qt.red),
                                    QPen(Qt.black, 2),
                                    QSize(9, 9)),
        errorPen = QPen(Qt.blue, 2),
        errorCap = 10,
        errorOnTop = errorOnTop,
        )
    curve.attach(demo)
    demo.resize(640, 480)
    demo.show()
    return demo
Esempio n. 11
0
    def __init__(self, parent=None):
        super(Mision, self).__init__(parent)
        layout = QGridLayout(self)
        layout.lb1 = QLabel(self)
        x=0
        layout.lb1.setPixmap(QPixmap("CANSAT_BKG.png"))
        layout.lb1.setGeometry(0, 0, 1500, 1000)

        ############################TITLE#############################
        font = QFont("UKNumberPlate", 20, 10, 0)  #### FUENTE, TAMAÑO, GROSOR, ITALICA 0-F
        titulo1=QLabel()
        titulo1.setFont(font)
        titulo1.setStyleSheet('color: white')
        titulo1.setText('TEAM THOR')
        layout.addWidget(titulo1,0,1)
        #############################################################
        x = [1, 2]
        y = [1, 2]
        layout.addWidget(grap1, 1, 0)
 ##############################################################
        graph2 = QwtPlot()
        curva2 = QwtPlotCurve()
        curva3 = QwtPlotCurve()
        xcurva2 = [-800, 800]
        ycurva2 = [0, 0]
        xcurva3 = [0, 0]
        ycurva3 = [-800, 800]
        curva2.setData(xcurva2, ycurva2)
        curva2.setPen(QPen(Qt.black))
        curva2.attach(graph2)
        curva3.setData(xcurva3, ycurva3)
        curva3.setPen(QPen(Qt.black))
        curva3.attach(graph2)
        pal = QPalette();
        pal.setColor(QPalette.Text, Qt.white)
        pal.setColor(QPalette.Foreground, Qt.white)
        layout.addWidget(graph2, 2, 0)
        grid = QwtPlotGrid()
        grid.attach(graph2)
        grid.setPen(QPen(Qt.black, 0, Qt.DotLine))
        graph2.replot()
        graph2.setAxisScale(QwtPlot.xBottom, -800, 800)
        graph2.setAxisScale(QwtPlot.yLeft, -800, 800)
        graph2.setPalette(pal)
#############################################################)
        layoutv = QVBoxLayout()
        layoutvN = QVBoxLayout()
        lb1 = QLabel(self)
        pixmap=QPixmap("DIAL4.png")
        pixmap2 = QPixmap("pointer.png")
        pixmap = pixmap.scaledToWidth(220)
        pixmap2 = pixmap2.scaledToWidth(20)
        lb1.setPixmap(pixmap)
        layoutv.addWidget(text_pressure)
        layoutv.addWidget(lb1)
        frame5.setLayout(layoutv)
        layoutvN.addWidget(frame5)
        layout.addLayout(layoutvN, 1, 1)
        ###
        self.lbN = QLabel(self)
        #x=50400
        press=0
        ang=(0.002685)*press-140
        if ang>=0:
            correctionx =  0
            correctiony=round(ang*0.2)
        else:
            correctiony = - round(ang * 0.2)
            if ang<=-105:
                correctionx = -round((((-ang-100)*0.07)**(2))-40)
            else:
                if ang>=-9.4:
                    correctionx = round(12 * (((-ang-1)/100) ** (1 / 4)))
                else:
                    correctionx = round(12 * (((-ang -9.5)) ** (1 / 4)))
        t = QTransform()
        t.rotate(ang)
        rotated_pixmap = pixmap2.transformed(t, Qt.SmoothTransformation)
        #lbN = QLabel(self)
        self.lbN.setPixmap(rotated_pixmap)
        self.lbN.setGeometry(619 - correctionx, 180 + correctiony, 70, 70)
        layout.lbN= self.lbN
        #layout.lbN.setPixmap(rotated_pixmap)
        #layout.lbN.setGeometry(619-correctionx, 180 + correctiony, 70, 70)
        #ang2.correctiony
#############################################################

############################################################
        layouth1 = QHBoxLayout()
        layouth2 = QHBoxLayout()
        layouth1.addWidget(volt_bar)
        layouth1.addWidget(text_volt)
        frame3.setLayout(layouth1)
        layouth2.addWidget(frame3)
        layout.addLayout(layouth2, 1, 2)
############################################################
        layoutG = QVBoxLayout()
        layoutG2 = QVBoxLayout()
        layoutG3 = QVBoxLayout()
        layoutG4 = QVBoxLayout()
        layoutG5 = QVBoxLayout()
        layoutG.addWidget(text_gps_time)
        layoutG.addWidget(text_gps_la)
        layoutG.addWidget(text_gps_lo)
        layoutG.addWidget(text_gps_al)
        layoutG.addWidget(text_gps_sats)
        layoutG3.addWidget(text_teamId)
        layoutG3.addWidget(text_mission_time)
        layoutG3.addWidget(text_Packet_count)
        frame2.setLayout(layoutG)
        frame7.setLayout(layoutG3)
        layoutG2.addWidget(frame2)
        layoutG4.addWidget(frame7)
        layoutG5.addLayout(layoutG2)
        layoutG5.addLayout(layoutG4)
        layout.addLayout(layoutG5, 2,2)
############################################################
        vboxj3 = QVBoxLayout()
        layoutG3 = QVBoxLayout()
        vboxj3.addWidget(text_sys)
        vboxj3.addWidget(text_elevation)
        vboxj3.addWidget(text_azimut)
        vboxj3.addWidget(text_gs_to_cansat)
        vboxj3.addWidget(text_space)
        frame1.setLayout(vboxj3)
        layoutG3.addWidget(frame1)
        layout.addLayout(layoutG3, 1, 3)
###########################################################
        layout.setContentsMargins(0,0,0,0)
        layout.setSpacing(40)
############################################################
        layouth3 = QVBoxLayout()
        layouth4 = QVBoxLayout()
        layouth3.addWidget(temp_text)
        layouth3.addWidget(temp_bar)
        frame4.setLayout(layouth3)
        layouth4.addWidget(frame4)
        layout.addLayout(layouth4, 2, 3)
        temp_bar.setStyleSheet('QProgressBar::chunk {background: rgb(255, 0, 0);}')
############################################################
        self.setLayout(layout)
Esempio n. 12
0
    def __init__(self, *args):
        QwtPlot.__init__(self, *args)
        # set plot title
        self.setTitle('ImagePlot')
        # set plot layout
        self.plotLayout().setCanvasMargin(0)
        self.plotLayout().setAlignCanvasToScales(True)
        # set legend
        legend = QwtLegend()
        legend.setDefaultItemMode(QwtLegendData.Clickable)
        self.insertLegend(legend, QwtPlot.RightLegend)
        # set axis titles
        self.setAxisTitle(QwtPlot.xBottom, 'time (s)')
        self.setAxisTitle(QwtPlot.yLeft, 'frequency (Hz)')

        colorMap = QwtLinearColorMap(Qt.blue, Qt.red)
        interval = QwtInterval(-1, 1)
        self.enableAxis(QwtPlot.yRight)
        self.setAxisScale(QwtPlot.yRight, -1, 1)
        self.axisWidget(QwtPlot.yRight).setColorBarEnabled(True)
        self.axisWidget(QwtPlot.yRight).setColorMap(interval, colorMap)

        # calculate 3 NumPy arrays
        x = np.arange(-2*np.pi, 2*np.pi, 0.01)
        y = np.pi*np.sin(x)
        z = 4*np.pi*np.cos(x)*np.cos(x)*np.sin(x)
        # attach a curve
        curve = QwtPlotCurve('y = pi*sin(x)')
        curve.attach(self)
        curve.setPen(QPen(Qt.green, 2))
        curve.setData(x, y)
        # attach another curve
        curve = QwtPlotCurve('y = 4*pi*sin(x)*cos(x)**2')
        curve.attach(self)
        curve.setPen(QPen(Qt.black, 2))
        curve.setData(x, z)
        # attach a grid
        grid = QwtPlotGrid()
        grid.attach(self)
        grid.setPen(QPen(Qt.black, 0, Qt.DotLine))
        # attach a horizontal marker at y = 0
        marker = QwtPlotMarker()
        marker.attach(self)
        marker.setValue(0.0, 0.0)
        marker.setLineStyle(QwtPlotMarker.HLine)
        marker.setLabelAlignment(Qt.AlignRight | Qt.AlignTop)
        marker.setLabel(QwtText('y = 0'))
        # attach a vertical marker at x = pi
        marker = QwtPlotMarker()
        marker.attach(self)
        marker.setValue(np.pi, 0.0)
        marker.setLineStyle(QwtPlotMarker.VLine)
        marker.setLabelAlignment(Qt.AlignRight | Qt.AlignBottom)
        marker.setLabel(QwtText('x = pi'))
        # attach a plot image
        plotImage = PlotImage('Image')
        plotImage.attach(self)
        plotImage.setData(square(512, -2*np.pi, 2*np.pi),
                          (-2*np.pi, 2*np.pi), (-2*np.pi, 2*np.pi))

        legend.SIG_CLICKED.connect(self.toggleVisibility)
        
        # replot
        self.replot()
Esempio n. 13
0
    def __init__(self, *args):
        QwtPlot.__init__(self, *args)
        # set plot title
        self.setTitle("ImagePlot")
        # set plot layout
        self.plotLayout().setCanvasMargin(0)
        self.plotLayout().setAlignCanvasToScales(True)
        # set legend
        legend = QwtLegend()
        legend.setDefaultItemMode(QwtLegendData.Clickable)
        self.insertLegend(legend, QwtPlot.RightLegend)
        # set axis titles
        self.setAxisTitle(QwtPlot.xBottom, "time (s)")
        self.setAxisTitle(QwtPlot.yLeft, "frequency (Hz)")

        colorMap = QwtLinearColorMap(Qt.blue, Qt.red)
        interval = QwtInterval(-1, 1)
        self.enableAxis(QwtPlot.yRight)
        self.setAxisScale(QwtPlot.yRight, -1, 1)
        self.axisWidget(QwtPlot.yRight).setColorBarEnabled(True)
        self.axisWidget(QwtPlot.yRight).setColorMap(interval, colorMap)

        # calculate 3 NumPy arrays
        x = np.arange(-2 * np.pi, 2 * np.pi, 0.01)
        y = np.pi * np.sin(x)
        z = 4 * np.pi * np.cos(x) * np.cos(x) * np.sin(x)
        # attach a curve
        QwtPlotCurve.make(x,
                          y,
                          title="y = pi*sin(x)",
                          linecolor=Qt.green,
                          linewidth=2,
                          plot=self)
        # attach another curve
        QwtPlotCurve.make(x,
                          z,
                          title="y = 4*pi*sin(x)*cos(x)**2",
                          linewidth=2,
                          plot=self)
        # attach a grid
        grid = QwtPlotGrid()
        grid.attach(self)
        grid.setPen(QPen(Qt.black, 0, Qt.DotLine))
        # attach a horizontal marker at y = 0
        QwtPlotMarker.make(
            label="y = 0",
            linestyle=QwtPlotMarker.HLine,
            align=Qt.AlignRight | Qt.AlignTop,
            plot=self,
        )
        # attach a vertical marker at x = pi
        QwtPlotMarker.make(
            np.pi,
            0.0,
            label="x = pi",
            linestyle=QwtPlotMarker.VLine,
            align=Qt.AlignRight | Qt.AlignBottom,
            plot=self,
        )
        # attach a plot image
        plotImage = PlotImage("Image")
        plotImage.attach(self)
        plotImage.setData(
            square(512, -2 * np.pi, 2 * np.pi),
            (-2 * np.pi, 2 * np.pi),
            (-2 * np.pi, 2 * np.pi),
        )

        legend.clicked.connect(self.toggleVisibility)

        # replot
        self.replot()
Esempio n. 14
0
    def __init__(self, *args):
        QwtPlot.__init__(self, *args)
        # set plot title
        self.setTitle('ImagePlot')
        # set plot layout
        self.plotLayout().setCanvasMargin(0)
        self.plotLayout().setAlignCanvasToScales(True)
        # set legend
        legend = QwtLegend()
        legend.setDefaultItemMode(QwtLegendData.Clickable)
        self.insertLegend(legend, QwtPlot.RightLegend)
        # set axis titles
        self.setAxisTitle(QwtPlot.xBottom, 'time (s)')
        self.setAxisTitle(QwtPlot.yLeft, 'frequency (Hz)')

        colorMap = QwtLinearColorMap(Qt.blue, Qt.red)
        interval = QwtInterval(-1, 1)
        self.enableAxis(QwtPlot.yRight)
        self.setAxisScale(QwtPlot.yRight, -1, 1)
        self.axisWidget(QwtPlot.yRight).setColorBarEnabled(True)
        self.axisWidget(QwtPlot.yRight).setColorMap(interval, colorMap)

        # calculate 3 NumPy arrays
        x = np.arange(-2 * np.pi, 2 * np.pi, 0.01)
        y = np.pi * np.sin(x)
        z = 4 * np.pi * np.cos(x) * np.cos(x) * np.sin(x)
        # attach a curve
        curve = QwtPlotCurve('y = pi*sin(x)')
        curve.attach(self)
        curve.setPen(QPen(Qt.green, 2))
        curve.setData(x, y)
        # attach another curve
        curve = QwtPlotCurve('y = 4*pi*sin(x)*cos(x)**2')
        curve.attach(self)
        curve.setPen(QPen(Qt.black, 2))
        curve.setData(x, z)
        # attach a grid
        grid = QwtPlotGrid()
        grid.attach(self)
        grid.setPen(QPen(Qt.black, 0, Qt.DotLine))
        # attach a horizontal marker at y = 0
        marker = QwtPlotMarker()
        marker.attach(self)
        marker.setValue(0.0, 0.0)
        marker.setLineStyle(QwtPlotMarker.HLine)
        marker.setLabelAlignment(Qt.AlignRight | Qt.AlignTop)
        marker.setLabel(QwtText('y = 0'))
        # attach a vertical marker at x = pi
        marker = QwtPlotMarker()
        marker.attach(self)
        marker.setValue(np.pi, 0.0)
        marker.setLineStyle(QwtPlotMarker.VLine)
        marker.setLabelAlignment(Qt.AlignRight | Qt.AlignBottom)
        marker.setLabel(QwtText('x = pi'))
        # attach a plot image
        plotImage = PlotImage('Image')
        plotImage.attach(self)
        plotImage.setData(square(512, -2 * np.pi, 2 * np.pi),
                          (-2 * np.pi, 2 * np.pi), (-2 * np.pi, 2 * np.pi))

        legend.SIG_CLICKED.connect(self.toggleVisibility)

        # replot
        self.replot()
Esempio n. 15
0
class SimplePlot_on(QwtPlot):
    def __init__(self, *args):
        # colors = [Qt.Qt.red, Qt.Qt.yellow, Qt.Qt.green, Qt.Qt.blue, Qt.Qt.cyan, Qt.Qt.magenta, Qt.Qt.gray, Qt.Qt.white,
        #           Qt.Qt.darkRed, Qt.Qt.darkYellow, Qt.Qt.darkGreen, Qt.Qt.darkBlue, Qt.Qt.darkCyan,
        #           Qt.Qt.darkMagenta, Qt.Qt.lightGray, Qt.Qt.darkGray]
        #colors = [Qt.red, Qt.darkRed, Qt.green, Qt.darkGreen, Qt.blue,
        #          Qt.darkBlue, Qt.cyan, Qt.darkCyan, Qt.magenta,
        #          Qt.darkMagenta, Qt.yellow, Qt.darkYellow, Qt.gray,
        #          Qt.darkGray, Qt.lightGray, Qt.black]
        colors = [
            QColor('#CC0000'),
            QColor('#FF3333'),
            QColor('#CC6600'),
            QColor('#FF9933'),
            QColor('#CCCC00'),
            QColor('#FFFF33'),
            QColor('#66CC00'),
            QColor('#00CCCC'),
            QColor('#33FFFF'),
            QColor('#0066CC'),
            QColor('#3399FF'),
            QColor('#3399FF'),
            QColor('#0000CC'),
            QColor('#6600CC'),
            QColor('#9933FF'),
            QColor('#CC00CC'),
            QColor('#FF33FF'),
            QColor('#CC0066'),
            QColor('#FF3399'),
            QColor('#C0C0C0')
        ]
        QwtPlot.__init__(self, *args)

        self.setCanvasBackground(Qt.black)
        self.alignScales()

        # grid
        self.grid = QwtPlotGrid()
        self.grid.attach(self)
        self.grid.setPen(QPen(Qt.white, 0, Qt.DotLine))

        # setting axis title. The yLeft axis title can chance to 'Temperature', depending on plot preferences
        self.setAxisTitle(QwtPlot.xBottom, 'Time [hh:mm:ss]')
        self.setAxisTitle(QwtPlot.yLeft, 'Height [mm]')

        # Habilita e denomina eixo Y2
        self.enableAxis(QwtPlot.yRight)
        self.setAxisTitle(QwtPlot.yRight, 'Temperature[ºC]')

        self.nplots = 40
        self.Plots = np.array([])
        self.Data = np.array([])

        for i in range(self.nplots):
            self.Plots = np.append(self.Plots, QwtPlotCurve())
            if (i % 2 == 0):
                pen = QPen(colors[int(i / 2)], 1, Qt.SolidLine)
            else:
                pen = QPen(colors[int(i / 2)], 1, Qt.DashLine)
            self.Plots[i].setPen(pen)
            self.Plots[i].attach(self)
            """define como valor plotado será escrito no eixo x"""
            self.setAxisScaleDraw(QwtPlot.xBottom, TimeScaleDraw())
            self.Data = np.append(self.Data, dataclass())

            if divmod(i, 2)[1] == 1:
                self.Plots[i].setYAxis(QwtPlot.yRight)
            # define a tupple that will contain plot data, expressed in cartesian coordinates
            self.Plots[i].setData(self.Data[i].x, self.Data[i].y)

        # legend
        # self.legend = QwtLegend()
        # self.legend.setFrameStyle(QFrame.Box)
        self.insertLegend(QwtLegend(), QwtPlot.BottomLegend)

        # replot
        self.replot()

        # zoom
        # self.zoomer = QwtPlotZoomer(QwtPlot.xBottom,
        #                                 QwtPlot.yLeft,
        #                                 QwtPicker.DragSelection,
        #                                 QwtPicker.AlwaysOn,
        #                                 self.canvas())
        #
        # self.zoomer.setRubberBandPen(QPen(Qt.green))
        self.startTimer(50)

    def alignScales(self):
        self.canvas().setFrameStyle(QFrame.Box | QFrame.Plain)
        self.canvas().setLineWidth(1)
        for i in range(QwtPlot.axisCnt):
            scaleWidget = self.axisWidget(i)
            if scaleWidget:
                scaleWidget.setMargin(0)
            scaleDraw = self.axisScaleDraw(i)
            if scaleDraw:
                scaleDraw.enableComponent(QwtAbstractScaleDraw.Backbone, False)

    def timerEvent(self, e):
        try:
            for i in range(self.nplots):
                self.Plots[i].setData(self.Data[i].x, self.Data[i].y)
            self.replot()
        except:
            pass
Esempio n. 16
0
class SimplePlot(QwtPlot):
    def __init__(self, *args):

        colors = [
            Qt.red, Qt.darkRed, Qt.green, Qt.darkGreen, Qt.blue, Qt.darkBlue,
            Qt.cyan, Qt.darkCyan, Qt.magenta, Qt.darkMagenta, Qt.yellow,
            Qt.darkYellow, Qt.gray, Qt.darkGray, Qt.lightGray, Qt.black
        ]
        QwtPlot.__init__(self, *args)

        self.setCanvasBackground(Qt.white)
        self.alignScales()

        # grid
        self.grid = QwtPlotGrid()
        self.grid.attach(self)
        self.grid.setPen(QPen(Qt.black, 0, Qt.DotLine))

        # set titles
        self.setTitle("Gráfico")
        self.setAxisTitle(QwtPlot.xBottom, 'Tempo [hh:mm:ss] -->')
        self.setAxisTitle(QwtPlot.yLeft, 'Nível [mm] -->')
        """Habilita e denomina eixo Y2"""
        self.enableAxis(QwtPlot.yRight)
        self.setAxisTitle(QwtPlot.yRight, '<-- Temp. [ºC]')

        self.nplots = 16
        self.Plots = np.array([])
        self.Data = np.array([])

        for i in range(self.nplots):
            self.Plots = np.append(self.Plots, QwtPlotCurve())
            self.Plots[i].setPen(QPen(colors[i]))
            self.Plots[i].attach(self)
            """define como valor plotado será escrito no eixo x"""
            self.setAxisScaleDraw(QwtPlot.xBottom, TimeScaleDraw())
            self.Data = np.append(self.Data, dataclass())
            """Os índices pares se referem à plots no eixo Y1,
            e os índices ímpares são ligados ao eixo Y2"""
            if divmod(i, 2)[1] == 1:
                self.Plots[i].setYAxis(QwtPlot.yRight)
            self.Plots[i].setData(self.Data[i].x, self.Data[i].y)

        # legend
        #self.legend = QwtLegend
        #QwtLegend().setFrameStyle(QFrame.Box)
        #self.insertLegend(QwtLegend().setFrameStyle(QFrame.Box), QwtPlot.BottomLegend)
        self.insertLegend(QwtLegend(), QwtPlot.BottomLegend)

        # replot
        self.replot()

        # zoom
        # self.zoomer = QwtPlotZoomer(QwtPlot.xBottom,
        #                                 QwtPlot.yLeft,
        #                                 QwtPicker.DragSelection,
        #                                 QwtPicker.AlwaysOn,
        #                                 self.canvas())
        #
        # self.zoomer.setRubberBandPen(QPen(Qt.green))
        self.startTimer(50)

    def alignScales(self):
        self.canvas().setFrameStyle(QFrame.Box | QFrame.Plain)
        self.canvas().setLineWidth(1)
        for i in range(QwtPlot.axisCnt):
            scaleWidget = self.axisWidget(i)
            if scaleWidget:
                scaleWidget.setMargin(0)
            scaleDraw = self.axisScaleDraw(i)
            if scaleDraw:
                scaleDraw.enableComponent(QwtAbstractScaleDraw.Backbone, False)

    def timerEvent(self, e):
        try:
            for i in range(self.nplots):
                self.Plots[i].setData(self.Data[i].x, self.Data[i].y)
            self.replot()
        except:
            pass
Esempio n. 17
0
    def __init__(self, parent=None):
        super(Mision, self).__init__(parent)
        layout = QGridLayout(self)
        layout.lb1 = QLabel(self)
        layout.IM1=QLabel(self)
        layout.IM2=QLabel(self)
        layout.IM3=QLabel(self)
        layout.IM4 = QLabel(self)
        layout.IM5 = QLabel(self)
        layout.IM1.setPixmap(QPixmap("ipn.png"))
        layout.IM1.setGeometry(1250, 0, 120, 90)
        layout.IM2.setPixmap(QPixmap("mexico.png"))
        layout.IM2.setGeometry(1160, 0, 120, 90)
        layout.IM3.setPixmap(QPixmap("upiita.png"))
        layout.IM3.setGeometry(80, 0, 120, 90)
        layout.IM4.setPixmap(QPixmap("CANSATCOMP.png"))
        layout.IM4.setGeometry(500, 30, 180, 90)
        layout.IM5.setPixmap(QPixmap("IPNUPIITA.png"))
        layout.IM5.setGeometry(700, 30, 180, 90)
        ###############
        layout.lb1.setPixmap(QPixmap("CANSAT_BKG.png"))
        layout.lb1.setGeometry(0, 0, 1500, 1000)

        ############################TITLE#############################
        titulo1=QLabel()
        teamthor = QPixmap("TEAM3.png")
        titulo1.setPixmap(teamthor)
        layout.addWidget(titulo1,0,1)
        #############################################################
        x = [1, 2]
        y = [1, 2]
        layout.addWidget(grap1, 1, 0)
 ##############################################################
        graph2 = QwtPlot()
        curva2 = QwtPlotCurve()
        curva3 = QwtPlotCurve()
        xcurva2 = [-800, 800]
        ycurva2 = [0, 0]
        xcurva3 = [0, 0]
        ycurva3 = [-800, 800]
        curva2.setData(xcurva2, ycurva2)
        curva2.setPen(QPen(Qt.black))
        curva2.attach(graph2)
        curva3.setData(xcurva3, ycurva3)
        curva3.setPen(QPen(Qt.black))
        curva3.attach(graph2)
        pal = QPalette();
        pal.setColor(QPalette.Text, Qt.white)
        pal.setColor(QPalette.Foreground, Qt.white)
        layout.addWidget(graph2, 2, 0)
        grid = QwtPlotGrid()
        grid.attach(graph2)
        grid.setPen(QPen(Qt.black, 0, Qt.DotLine))
        graph2.replot()
        graph2.setAxisScale(QwtPlot.xBottom, -800, 800)
        graph2.setAxisScale(QwtPlot.yLeft, -800, 800)
        graph2.setPalette(pal)
#############################################################)
        layoutv = QGridLayout()
        layoutvN = QVBoxLayout()
        lb1 = QLabel(self)
        pixmap=QPixmap("DIAL4.png")
        pixmap = pixmap.scaledToWidth(220)
        lb1.setPixmap(pixmap)
        layoutv.addWidget(text_pressure,0,0)
        layoutv.addWidget(lb1,1,0)
        layoutv.addWidget(ql1,1,0,Qt.AlignCenter)
        frame5.setLayout(layoutv)
        layoutvN.addWidget(frame5)
        layout.addLayout(layoutvN, 1, 1)
#############################################################
        layoutvp = QGridLayout()
        layoutvNp = QVBoxLayout()
        lb1p = QLabel(self)
        pixmapp = QPixmap("DIAL4.png")
        pixmapp = pixmap.scaledToWidth(160)
        lb1p.setPixmap(pixmapp)
        layoutvp.addWidget(text_pitch, 0, 0)
        layoutvp.addWidget(text_roll, 1, 0)
        layoutvp.addWidget(text_bladespin, 2, 0)
        layoutvp.addWidget(lb1p, 3, 0 ,Qt.AlignCenter)
        layoutvp.addWidget(ql1p, 3, 0, Qt.AlignCenter)
        frame6.setLayout(layoutvp)
        layoutvNp.addWidget(frame6)
        layout.addLayout(layoutvNp, 2, 1)
############################################################
        layouth1 = QHBoxLayout()
        layouth2 = QHBoxLayout()
        layouth1.addWidget(volt_bar)
        layouth1.addWidget(text_volt)
        frame3.setLayout(layouth1)
        layouth2.addWidget(frame3)
        layout.addLayout(layouth2, 1, 2)
############################################################
        layoutG = QVBoxLayout()
        layoutG2 = QVBoxLayout()
        layoutG3 = QVBoxLayout()
        layoutG4 = QVBoxLayout()
        layoutG5 = QVBoxLayout()
        layoutG.addWidget(text_gps_time)
        layoutG.addWidget(text_gps_la)
        layoutG.addWidget(text_gps_lo)
        layoutG.addWidget(text_gps_al)
        layoutG.addWidget(text_gps_sats)
        layoutG3.addWidget(text_teamId)
        layoutG3.addWidget(text_mission_time)
        layoutG3.addWidget(text_Packet_count)
        frame2.setLayout(layoutG)
        frame7.setLayout(layoutG3)
        layoutG2.addWidget(frame2)
        layoutG4.addWidget(frame7)
        layoutG5.addLayout(layoutG2)
        layoutG5.addLayout(layoutG4)
        layout.addLayout(layoutG5, 2,2)
############################################################
        vboxj3 = QVBoxLayout()
        layoutG3 = QVBoxLayout()
        vboxj3.addWidget(text_sys)
        vboxj3.addWidget(text_elevation)
        vboxj3.addWidget(text_azimut)
        vboxj3.addWidget(text_gs_to_cansat)
        vboxj3.addWidget(text_space)
        frame1.setLayout(vboxj3)
        layoutG3.addWidget(frame1)
        layout.addLayout(layoutG3, 1, 3)
###########################################################
        layout.setContentsMargins(0,0,0,0)
        layout.setSpacing(30)
############################################################
        layouth3 = QHBoxLayout()
        layouth4 = QHBoxLayout()
        layouth3.addWidget(temp_bar)
        layouth3.addWidget(temp_text)
        frame4.setLayout(layouth3)
        layouth4.addWidget(frame4)
        layout.addLayout(layouth4, 2, 3)
        temp_bar.setStyleSheet('QProgressBar::chunk {background: rgb(255, 0, 0);}')
        temp_bar.setRange(0, 350)
        temp_bar.setFixedSize(50, 200)
############################################################
        self.setLayout(layout)