from PyQt5 import Qt, QtCore, QtGui
import pyqtgraph as pg
import numpy as np
app = pg.mkQApp()
# Set Global pyqtgraph options
pg.setConfigOption('foreground', 'k') # Default foreground color for text, lines, axes, etc.
pg.setConfigOption('background', None) # Default background for GraphicsView.
pg.setConfigOptions(antialias=True) # Draw lines with smooth edges at the cost of reduced performance.
def stem_plot(pw, x, y):
curve = pw.plot(np.repeat(x, 2), np.dstack((np.zeros(y.shape[0], dtype=int), y)).flatten(), pen=pg.mkPen('b', width=1.5), connect='pairs', name='Stems')
curve = pw.plot(x, y, pen=None, symbol='o', symbolPen='b', symbolBrush=Qt.QBrush(Qt.Qt.gray), symbolSize=8, name='Points')
pw = pg.PlotWidget(enableMenu=False, title="Stem Plot Example")
x = np.arange(1,100)
y = np.arange(1,100)
stem_plot(pw, x, y)
pw.show()
## 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_()