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.
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..
Asked
Active
Viewed 991 times
1
3 Answers
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:
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()

tom10
- 67,082
- 10
- 127
- 137
-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
-
Thank you very much for your useful comments – Caute Jul 06 '16 at 14:41