from
PyQt5.QtWidgets
import
*
import
sys
import
numpy as np
import
pyqtgraph as pg
from
PyQt5.QtGui
import
*
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 Scatter Plot"
)
label.setWordWrap(
True
)
plot
=
pg.plot()
n
=
300
scatter
=
pg.ScatterPlotItem(
size
=
10
, brush
=
pg.mkBrush(
255
,
255
,
255
,
120
))
pos
=
np.random.normal(size
=
(
2
, n), scale
=
1e
-
5
)
spots
=
[{
'pos'
: pos[:, i],
'data'
:
1
}
for
i
in
range
(n)]
+
[{
'pos'
: [
0
,
0
],
'data'
:
1
}]
scatter.addPoints(spots)
plot.addItem(scatter)
layout
=
QGridLayout()
label.setMinimumWidth(
130
)
widget.setLayout(layout)
layout.addWidget(label,
1
,
0
)
layout.addWidget(plot,
0
,
1
,
3
,
1
)
self
.setCentralWidget(widget)
App
=
QApplication(sys.argv)
window
=
Window()
sys.exit(App.
exec
())