如何在 matplotlib 中以不等间隙缩放 x 轴
我必须使用下表:
并使用此代码创建以下图表:
代码:
plt.plot(new[201], label='201')
plt.genend()
plt.show()
图:
如何缩放 x 轴使其间隙不相等?
例如,如果我在 Excel 中使用相同的数据,我会得到以下图表:
那么我该如何制作python 中的图表与 excel 中的图表一样吗?
I have to following table:
and I create the following graph with this code:
code:
plt.plot(new[201], label='201')
plt.genend()
plt.show()
graph:
how can I scale the x-axis NOT to be with equal gaps?
for example, if I use the same data in excel I get this graph:
so how can I make the graph in python to be like in excel ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您似乎将数据作为字符串。 x 轴很可能被字符串值占据。您还没有提供数据,所以我不知道 new[201] 是什么样的。但是,我想您所需要的只是将其转换为浮动,例如:
当然,这是针对 numpy 数组的。如果您的数据具有不同的格式,请检查将其从字符串转换为浮点数的具体方法。
You seem to have your data as strings. Most likely the x-axis is occupied by string values. You have not provided the data, so I have no idea what new[201] looks like. However, I guess all you need is to cast it to float with something like:
Of course, this is for numpy array. In case your data have a different format, check the specific way to cast it from string to float.