def __init__(self, cpu_histogram):
super().__init__()
# set up the graphical elements
layout = QGridLayout(self)
self.setLayout(layout)
fig = Figure()
layout.addWidget(FigureCanvas(fig))
# do the plotting
ax = fig.add_subplot(1, 1, 1) # 1x1 grid, first subplot
ax.set_title('CPU Usage Histogram (%s Cores/%s Threads)' % (psutil.cpu_count(False), psutil.cpu_count(True)))
ax.set_ylabel('Count')
ax.set_xlabel('CPU %')
ax.grid(True)
xs = range(0, 101)
ax.plot(xs, [cpu_histogram[x] for x in xs])
ax.xaxis.set_major_locator(MultipleLocator(10.))
self.show()
评论列表
文章目录