Home > Enterprise >  What does a string like 1e-6 6.0459e-1 mean in the context of a vertical axis label in a matplotlib
What does a string like 1e-6 6.0459e-1 mean in the context of a vertical axis label in a matplotlib

Time:02-05

I have a Python code that gives me plot like this one (made by matplotlib):

enter image description here

the mean value is about 0.6065

Then I change a parameter and, starting from a certain value, matplotlib automatically add a string like 1e-6 6.0459e-1 to the vertical axis:

enter image description here

What does it mean? Maybe that there is a "reference" y-value at 6.0459e-1 and there is an oscillation peak to peak of about 5e-6?

CodePudding user response:

It means that each number y on the vertical axis is actually y * 10**-6 6.0459 * 10**-1.

In other words, the sine curve is basically the flat line 6.0459 * 10**-1 (a.k.a. 0.60459) that has some additive "noise" (the sine curve) of the order of 10**-6, which is a very small number.

You can force a more legible scale with something like plt.ylim(0.604, 0.605).


I think this is documented in the "Offset notation and scientific notation" section of the documentation for matplotlib.ticker.ScalarFormatter:

Offset notation and scientific notation look quite similar at first sight. Both split some information from the formatted tick values and display it at the end of the axis.

  • The scientific notation splits up the order of magnitude, i.e. a multiplicative scaling factor, e.g. 1e6.
  • The offset notation separates an additive constant, e.g. 1e6. The offset notation label is always prefixed with a or - sign and is thus distinguishable from the order of magnitude label.

Thus, in 1e-6 6.0459e-1:

  • 1e-6 is the order of magnitude in scientific notation
  • 6.0459e-1 is the offset in scientific notation
  •  Tags:  
  • Related