[英]Plotting a curve from numpy array with large values
I am trying to plot a curve from molecular dynamics potential energies data stored in numpy array. 我试图从存储在numpy数组中的分子动力学势能数据绘制曲线。 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. 从附图中可以看出,在图的左上角,出现了一个与y轴上的标签相关的大数字。 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.. 非常感谢你..
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". 这就是-
符号在数字前面的意思,“取绘制的y值并减去这个数字得到实际值”。 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: 但减去平均值(或接近该值的其他数字,如min
或max
等)将删除大偏移量:
plt.figure()
plt.plot(y - np.mean(y))
plt.ylabel("offset units")
plt.show()
您可以使用以下方法删除偏移:
plt.ticklabel_format(useOffset=False)
It seems your data is displayed in exponential form like: 1e+10, 2e+10, etc. This question here might help: 您的数据似乎以指数形式显示,如:1e + 10,2e + 10等。这里的问题可能会有所帮助:
How to prevent numbers being changed to exponential form in Python matplotlib figure 如何在Python matplotlib图中防止数字被改为指数形式
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.