36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""
|
|
This example demonstrates some of the plotting items available in pyqtgraph.
|
|
"""
|
|
|
|
import initExample ## Add path to library (just for examples; you do not need this)
|
|
from pyqtgraph.Qt import QtGui, QtCore
|
|
import numpy as np
|
|
import pyqtgraph as pg
|
|
|
|
|
|
app = QtGui.QApplication([])
|
|
win = pg.GraphicsWindow(title="Plotting items examples")
|
|
win.resize(1000,600)
|
|
win.setWindowTitle('pyqtgraph example: plotting with items')
|
|
|
|
# Enable antialiasing for prettier plots
|
|
pg.setConfigOptions(antialias=True)
|
|
|
|
p1 = win.addPlot(title="Plot Items example", y=np.random.normal(size=100))
|
|
inf1 = pg.InfiniteLine(movable=True, angle=90, label=True, textColor=(200,200,100), textFill=(200,200,200,50))
|
|
inf2 = pg.InfiniteLine(movable=True, angle=0, label=True, pen=(0, 0, 200), bounds = [-2, 2], unit="mm", hoverPen=(0,200,0))
|
|
inf3 = pg.InfiniteLine(movable=True, angle=45)
|
|
inf1.setPos([2,2])
|
|
p1.addItem(inf1)
|
|
p1.addItem(inf2)
|
|
p1.addItem(inf3)
|
|
lr = pg.LinearRegionItem(values=[0, 10])
|
|
p1.addItem(lr)
|
|
|
|
## Start Qt event loop unless running in interactive mode or using pyside.
|
|
if __name__ == '__main__':
|
|
import sys
|
|
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
|
|
QtGui.QApplication.instance().exec_()
|