2016-01-15 15:10:24 +00:00
|
|
|
# -*- 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)
|
|
|
|
|
|
|
|
# Enable antialiasing for prettier plots
|
|
|
|
pg.setConfigOptions(antialias=True)
|
|
|
|
|
|
|
|
p1 = win.addPlot(title="Plot Items example", y=np.random.normal(size=100))
|
2016-02-16 05:48:59 +00:00
|
|
|
inf1 = pg.InfiniteLine(movable=True, angle=90, label=True, textPosition=[0.5, 0.2], textColor=(200,200,100), textFill=(200,200,200,50))
|
2016-02-16 07:14:53 +00:00
|
|
|
inf2 = pg.InfiniteLine(movable=True, angle=0, label=True, pen=(0, 0, 200), textColor=(200,0,0), bounds = [-2, 2], suffix="mm", hoverPen=(0,200,0), draggableLabel=True)
|
2016-02-05 12:57:51 +00:00
|
|
|
inf3 = pg.InfiniteLine(movable=True, angle=45)
|
2016-01-15 15:10:24 +00:00
|
|
|
inf1.setPos([2,2])
|
2016-02-16 05:48:59 +00:00
|
|
|
inf1.setTextLocation(position=0.75)
|
|
|
|
inf2.setTextLocation(shift=0.8)
|
2016-01-15 15:10:24 +00:00
|
|
|
p1.addItem(inf1)
|
|
|
|
p1.addItem(inf2)
|
2016-02-05 12:57:51 +00:00
|
|
|
p1.addItem(inf3)
|
2016-02-16 07:14:53 +00:00
|
|
|
|
|
|
|
lr = pg.LinearRegionItem(values=[5, 10])
|
2016-01-15 15:10:24 +00:00
|
|
|
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_()
|