How to format digits after decimal point on Y-axis?

34 views
Skip to first unread message

Иван Никитин

unread,
Jan 16, 2020, 7:45:28 PM1/16/20
to pyqtgraph

How to change AxisItem style from this:
0.123456
0.123
0.12

to this:
0.12345
0.12300
0.12000

?

Carlos Pascual

unread,
Jan 17, 2020, 2:45:07 AM1/17/20
to pyqt...@googlegroups.com, Иван Никитин
Maybe there is a simpler solution, but you can subclass AxisItem
reimplementing the tickStrings method more or less like this:

```
class MyAxisItem(pg.AxisItem):
def tickStrings(self, values, scale, spacing):
return [ "%.5f" % v for v in values ]
```

...and then use this axis item in your plot

I hope this helps.
--
+----------------------------------------------------+
Carlos Pascual Izarra
Scientific Software Coordinator
Computing Division
ALBA Synchrotron [http://www.albasynchrotron.es]
Carrer de la Llum 2-26
E-08290 Cerdanyola del Valles (Barcelona), Spain
E-mail: cpas...@cells.es
Phone: +34 93 592 4428
+----------------------------------------------------+
Reply all
Reply to author
Forward
0 new messages