1

I am trying to plot a curve from molecular dynamics potential energies data stored in numpy array. As you can see from my figure attached, on the top left of the figure, a large number appears which is related to the label on y-axis. Look at it. enter image description here Even if I rescale the data, still a number appears there. I do not want it. Please can you suggest me howto sort out this issue? Thank you very much..

Psidom
  • 209,562
  • 33
  • 339
  • 356
Caute
  • 55
  • 1
  • 1
  • 4

3 Answers3

1

This is likely happening because your data is a small value offset by a large one. That's what the - sign means at the front of the number, "take the plotted y-values and subtract this number to get the actual values". You can remove it by plotting with the mean subtracted. Here's an example:

import numpy as np
import matplotlib.pyplot as plt

y = -1.5*1e7 + np.random.random(100)

plt.plot(y)
plt.ylabel("units")

gives the form you don't like: enter image description here

but subtracting the mean (or some other number close to that, like min or max, etc) will remove the large offset:

plt.figure()
plt.plot(y - np.mean(y))
plt.ylabel("offset units")
plt.show()

enter image description here

tom10
  • 67,082
  • 10
  • 127
  • 137
0

You can remove the offset by using:

plt.ticklabel_format(useOffset=False)
GWW
  • 43,129
  • 11
  • 115
  • 108
-1

It seems your data is displayed in exponential form like: 1e+10, 2e+10, etc. This question here might help:

How to prevent numbers being changed to exponential form in Python matplotlib figure

Community
  • 1
  • 1
Patrick K.
  • 14
  • 3