from
PyQt5.QtWidgets
import
*
import
sys
import
pyqtgraph as pg
from
PyQt5.QtGui
import
*
class
BarGraphItem(pg.BarGraphItem):
def
__init__(
self
,
*
args,
*
*
kwargs):
pg.BarGraphItem.__init__(
self
,
*
args,
*
*
kwargs)
def
mouseDoubleClickEvent(
self
, e):
self
.setScale(
0.2
)
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 Line Plot"
)
label.setWordWrap(
True
)
y
=
[
2
,
8
,
6
,
8
,
6
,
11
,
14
,
13
,
18
,
19
]
y2
=
[
3
,
1
,
5
,
8
,
9
,
11
,
16
,
17
,
14
,
16
]
x
=
range
(
0
,
10
)
plt
=
pg.plot()
plt.showGrid(x
=
True
, y
=
True
)
plt.addLegend()
plt.setLabel(
'left'
,
'Vertical Values'
, units
=
'y'
)
plt.setLabel(
'bottom'
,
'Horizontal Values'
, units
=
's'
)
plt.setXRange(
0
,
10
)
plt.setYRange(
0
,
20
)
line1
=
plt.plot(x, y, pen
=
'g'
, symbol
=
'x'
, symbolPen
=
'g'
, symbolBrush
=
0.2
, name
=
'green'
)
line2
=
plt.plot(x, y2, pen
=
'b'
, symbol
=
'o'
, symbolPen
=
'b'
, symbolBrush
=
0.2
, name
=
'blue'
)
value
=
line1.pixelPadding()
label.setText(
"Pixel Padding : "
+
str
(value))
label.setMinimumWidth(
120
)
layout
=
QGridLayout()
widget.setLayout(layout)
layout.addWidget(label,
1
,
0
)
layout.addWidget(plt,
0
,
1
,
3
,
1
)
self
.setCentralWidget(widget)
App
=
QApplication(sys.argv)
window
=
Window()
sys.exit(App.
exec
())