Pyqtgraph plotwidget:无法将轴刻度的字体粗细更改为粗体

Pyqtgraph plotwidget: cannot change font weight of axis ticks to BOLD

如何使 x 轴的刻度线加粗?

plot_1 = pg.PlotWidget()
plot_1.setBackground('w')
pen = pg.mkPen(color="k", width=3, style=QtCore.Qt.SolidLine)

plot_1 .setTitle("Title", color="k", size="18pt")
plot_1 .plot(xvals, yvals, pen=pen)
styles = {'color': 'r', 'font-size': '12px', 'font-weight': 'bold'}
plot_1 .setLabel('bottom', 'X label', **styles)

你必须使用setTickFont()方法来设置字体到轴:

fn = QtGui.QFont()
# fn.setPointSize(20)
fn.setBold(True)
plot_1.getAxis("bottom").setTickFont(fn)