import sys
from PySide.QtCore import *
from PySide.QtGui import *
import pyqtgraph as pg
class GraphWindow(QMainWindow):
def __init__(self, parent = None):
super(GraphWindow, self).__init__(parent)
#1 Create a PlotWidget
pw = pg.PlotWidget()
#1 Set the widget in the window
self.setCentralWidget(pw)
#1 Call plotItem
p1 = pw.plotItem
#1 Draw a scatter plot and a line graph
##2 Set the plot details
p1.addItem(pg.PlotCurveItem(x = [0, 1, 2, 3 ,4],
y = [0, 1, 2, 3 ,4],
pen = pg.mkPen(color = "r", style = Qt.SolidLine),
antialias = True))
p1.addItem(pg.ScatterPlotItem(x = [0, 1, 2, 3 ,4],
y = [4, 3, 2, 1, 0],
symbol = "x",
pen = pg.mkPen(None),
brush = pg.mkBrush("b"),
size = 7.5,
antialias = True))
if __name__ == '__main__':
#Create a Qt Application
app = QApplication(sys.argv)
#Create and display form
mainWin = GraphWindow()
mainWin.show()
#Start the main loop of Qt
sys.exit(app.exec_())
Recommended Posts