4

I'm trying to set the style the axis of a pyqtgraph.PlotWidget plotting area. I'm using:

font = QFont()
font.setPointSize(14)
font.setBold(True)
font.setWeight(75)

myPlotWidget.getAxis('left').setPen('b')
myPlotWidget.getAxis('left').setFont(font)

and I don't understand why the tick label color is not blue while the axis, grid and axis labels are.

enter image description here

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Alexis R Devitre
  • 288
  • 2
  • 6
  • 21

1 Answers1

5

You need to use AxisItem.setTextPen() explicitly:

self.graphWidget.getAxis('left').setTextPen('b')
musicamante
  • 41,230
  • 6
  • 33
  • 58
  • Thanks! It worked fine. I guess the name is not obvious. I skimmed through that doc several times and couldn't figure that's what I needed. – Alexis R Devitre Jul 03 '20 at 19:20
  • 3
    Actually, I didn't know about it until 10 minutes ago, I just did a `print(dir(self.graphWidget.getAxis('left')))` and looked for anything starting with "set" and containing "pen" ;-) – musicamante Jul 03 '20 at 19:22