Hi,
To modify my example from before, try something like:
self.plot = self.addPlot(title="Plot title")
font = self.plot.titleLabel.item.font()
font.setFamily("Serif")
p1.titleLabel.item.setFont(font)
I think the issue is that the reference to titleLabel is actually a
LabelItem object, so you then need to dig into it to get the reference to
item, which is the QGraphicsTextItem object within.
Patrick
On Tuesday, 19 February 2019 21:25:48 UTC+10:30, ip138 wrote:
>
> Thank you!
>
> That works perfect for everything, except for the title:
>
> font = self.plots[key]["item"].titleLabel.font()
> font.setFamily("Serif")
> self.plots[key]["item"].setFont(font)
>
>
> Is there anything I overlook?
>
> Greetings,
> Fabian
>
> On Tuesday, 19 February 2019 04:14:47 UTC+1, Patrick wrote:
>>
>> Hi,
>>
>> I don't know if this is the best way to do it, but something like this
>> works for axis labels:
>>
>> self.plot = self.addPlot()
>> self.plot.setLabels(left="Left axis")
>> font = self.plot.getAxis("left").label.font()
>> font.setFamily("Serif")
>> self.plot.getAxis("left").label.setFont(font)
>> self.plot.getAxis("left").setTickFont(font)
>>
>> For other items, you may need to do something similar, but look at the
>> code to see what the QtGui.QGraphicsTextItem is called. For example, for a
>> TextItem (
>> http://www.pyqtgraph.org/documentation/_modules/pyqtgraph/graphicsItems/TextItem.html#TextItem
>>
>> <http://www.google.com/url?q=http%3A%2F%2Fwww.pyqtgraph.org%2Fdocumentation%2F_modules%2Fpyqtgraph%2FgraphicsItems%2FTextItem.html%23TextItem&sa=D&sntz=1&usg=AFQjCNGQNEL_u8nhMp3Hskz2wvS7PUO38g>)
>>
>> you would use t.textItem.font() and t.textItem.setFont().
>>
>> Patrick
>>
>
--
You received this message because you are subscribed to the Google Groups
"pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/pyqtgraph/74b4d777-0a55-4ad0-b9c2-3799c7c51d35%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.