I have a custom font already uploaded as Qfont and I would like to apply it to the title of a PlotWidget.I managed to apply it to the tick axis labels but I had no luck so far with the title itself. This is how I managed for the axis:
import pyqtgraph as pq
from PyQt5 import QtGui
id = QtGui.QFontDatabase.addApplicationFont(cnst.ABS_FONT_PATH + 'Century18th.ttf')
_fontstr = QtGui.QFontDatabase.applicationFontFamilies(id)[0]
font= QtGui.QFont(_fontstr, 40)
....
widg = pq.PlotWidget(background=(0, 0, 0, 255), x=[0, 1, 2, 3], y=[0, 1, 2, 3],font= font,font_size= 30)
item= widg.getPlotItem()
item.getAxis("bottom").tickFont = font
item.getAxis("left").tickFont = font
is there something similar to tickFont for the Title? Setting the font parameter at the PlotWidget initialization doesn't change things for me...
Thank you a lot!!
In the end, I figured out a way to do this by looking in both the pyqtgraph and pyqt API details.
...
widg = pq.PlotWidget(background=(0, 0, 0, 255), x=[0, 1, 2, 3],
y=[0, 1, 2, 3],font= font,font_size= 30)
item= widg.getPlotItem()
item.titleLabel.item.setFont(font)
PS: There may be more elegant direct ways in the future if they expand the pyqtgraph API (current solution works for vs 0.10.0). Feel free to comment if you have found a smarter way :)