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
|
|
|
|
|
|
|
|
|
2021-01-27 18:05:56 +00:00
|
|
|
app = pg.mkQApp("InfiniteLine Example")
|
2018-02-16 04:15:32 +00:00
|
|
|
win = pg.GraphicsLayoutWidget(show=True, title="Plotting items examples")
|
2016-01-15 15:10:24 +00:00
|
|
|
win.resize(1000,600)
|
|
|
|
|
|
|
|
# Enable antialiasing for prettier plots
|
|
|
|
pg.setConfigOptions(antialias=True)
|
|
|
|
|
2016-02-28 20:26:05 +00:00
|
|
|
# Create a plot with some random data
|
2016-02-22 07:28:24 +00:00
|
|
|
p1 = win.addPlot(title="Plot Items example", y=np.random.normal(size=100, scale=10), pen=0.5)
|
|
|
|
p1.setYRange(-40, 40)
|
2016-02-28 20:26:05 +00:00
|
|
|
|
|
|
|
# Add three infinite lines with labels
|
2016-02-22 08:23:36 +00:00
|
|
|
inf1 = pg.InfiniteLine(movable=True, angle=90, label='x={value:0.2f}',
|
|
|
|
labelOpts={'position':0.1, 'color': (200,200,100), 'fill': (200,200,200,50), 'movable': True})
|
|
|
|
inf2 = pg.InfiniteLine(movable=True, angle=0, pen=(0, 0, 200), bounds = [-20, 20], hoverPen=(0,200,0), label='y={value:0.2f}mm',
|
|
|
|
labelOpts={'color': (200,0,0), 'movable': True, 'fill': (0, 0, 200, 100)})
|
2016-02-28 20:26:05 +00:00
|
|
|
inf3 = pg.InfiniteLine(movable=True, angle=45, pen='g', label='diagonal',
|
|
|
|
labelOpts={'rotateAxis': [1, 0], 'fill': (0, 200, 0, 100), 'movable': True})
|
2016-01-15 15:10:24 +00:00
|
|
|
inf1.setPos([2,2])
|
|
|
|
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
|
|
|
|
2016-02-28 20:26:05 +00:00
|
|
|
# Add a linear region with a label
|
2016-02-22 07:28:24 +00:00
|
|
|
lr = pg.LinearRegionItem(values=[70, 80])
|
2016-01-15 15:10:24 +00:00
|
|
|
p1.addItem(lr)
|
2016-02-28 20:26:05 +00:00
|
|
|
label = pg.InfLineLabel(lr.lines[1], "region 1", position=0.95, rotateAxis=(1,0), anchor=(1, 1))
|
|
|
|
|
2016-01-15 15:10:24 +00:00
|
|
|
|
|
|
|
## 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_()
|