from PyQt5.QtWidgets import *
import sys
import numpy as np
import pyqtgraph as pg
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from collections import namedtuple
class Window(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("PyQtGraph")
self.setGeometry(100, 100, 600, 500)
icon = QIcon("skin.png")
self.setWindowIcon(icon)
self.UiComponents()
self.show()
def UiComponents(self):
widget = QWidget()
label = QLabel("Geeksforgeeks Error Bar plot")
label.setMinimumWidth(130)
label.setWordWrap(True)
pg.setConfigOptions(antialias=True)
x = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
y = np.array([5, 4, 3, 2, 5, 6, 4, 8, 9, 8])
top = np.array([2, 2, 2, 2, 2, 2, 2, 2, 2, 2])
bottom = np.array([2, 2, 2, 2, 2, 2, 2, 2, 2, 2])
plt = pg.plot()
error = pg.ErrorBarItem(beam=0.5)
error.setData(x=x, y=y, top=top, bottom=bottom)
plt.addItem(error)
plt.plot(x, y, symbol='o', pen={'color': 0.8, 'width': 2})
layout = QGridLayout()
label.setMinimumWidth(130)
widget.setLayout(layout)
layout.addWidget(label, 1, 0)
layout.addWidget(plt, 0, 1, 3, 1)
self.setCentralWidget(widget)
error.moveBy(1, 1)
App = QApplication(sys.argv)
window = Window()
sys.exit(App.exec())