How to remove the automatic scaling prefix from axis label?

38 views
Skip to first unread message

Trifon Trifonov

unread,
Dec 20, 2018, 1:08:33 PM12/20/18
to pyqtgraph

Hi all,


So how do I remove the automatic scaling prefix from axis label?

See for example documentation from the AxisItem.setLabel


There on can read:


        units:           The units for this axis. Units should generally be given
                        without any scaling prefix (eg, 'V' instead of 'mV'). The
                        scaling prefix will be AUTOMATICALLY prepended based on the
                        range of data displayed.

But I don't want that!

in Astronomy we usually work with JD or BJD [days] and it is normal to have a large numberon the x-axis

See for example the attached plot.

How do I remove the 2.4558 (Md) and simply display 2455800 on the x-axis for example?

All the best,
Trifon
HD23472_ts1.png

stefan

unread,
Dec 20, 2018, 1:55:55 PM12/20/18
to pyqt...@googlegroups.com

Hi Trifon,

On 2018-12-20 1:08 p.m., Trifon Trifonov wrote:

Hi all,


So how do I remove the automatic scaling prefix from axis label?

See for example documentation from the AxisItem.setLabel

It seems this offers what you are asking for: http://www.pyqtgraph.org/documentation/graphicsItems/axisitem.html#pyqtgraph.AxisItem.enableAutoSIPrefix

Stefan
--

      ...ich hab' noch einen Koffer in Berlin...
    

Trifon Trifonov

unread,
Dec 20, 2018, 2:04:36 PM12/20/18
to pyqtgraph
Dear Stefan,

This indeed made the trick! Thank you very much!

However, now I have another problem :)

now the axes ticks are labeled as:

2.456+e06, which is Ok in general, but looks ugly in a paper plot.

any way that you know that i can display all the digits as they are in the time series without truncating?



All the best,
Trifon



stefan

unread,
Dec 20, 2018, 2:13:39 PM12/20/18
to pyqt...@googlegroups.com

I would like to know the answer to that question, too. :-)

Cheers,

Patrick

unread,
Dec 20, 2018, 9:47:18 PM12/20/18
to pyqtgraph
Hi,

This suggestion isn't elegant, but easy enough. If you never wanted pyqtgraph to use the e notation, then you could modify the code in AxisItem.py (http://www.pyqtgraph.org/documentation/_modules/pyqtgraph/graphicsItems/AxisItem.html#AxisItem.tickStrings), around line 756. Comment/delete the first part of the if block, and remove one level of indent from the vstr = (... in the else block:

            #~if abs(vs) < .001 or abs(vs) >= 10000:
               
#~vstr = "%g" % vs
           
#~else:
            vstr
= ("%%0.%df" % places) % vs

Patrick

Trifon Trifonov

unread,
Dec 21, 2018, 4:42:15 AM12/21/18
to pyqtgraph
Very good Patrick!

I was just about to start doing hacks in the code and your suggestion was to the point and very timely!
It works!
Thanks!

Trifon
Reply all
Reply to author
Forward
0 new messages