Reputation: 679
I see numbers on Y-axis like this:
1.935
1.9325
1.93
1.9275
1.925
But I need to see this:
1.9350
1.9325
1.9300
1.9275
1.9250
How can I set the AxisItem to show always fixed number of digits after decimal point?
Upvotes: 4
Views: 1121
Reputation: 2544
You need to subclass the AxisItem and use tickStrings to format the values:
class FmtAxisItem(pg.AxisItem):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def tickStrings(self, values, scale, spacing):
return [f'{v:.4f}' for v in values]
Then tell the plotter to use the axis:
self.chartWidget = pg.PlotWidget(axisItems={'left': FmtAxisItem(orientation='left')})
Upvotes: 6