Search code examples
pythonfontspyqtgraphxticks

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


How can I make x axis ticks bold?

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)

Solution

  • You have to use the setTickFont() method to set the font to the axis:

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