2024-10-03 13:22:05 发布
网友
所有人!我需要使用matplotlib(不一定)从单个图形中的四个数组绘制多条线。目前我的代码是
plt.plot(PTime,PReactions,NYTime,NYReactions,LTime,LReactions,SFTime,SFReactions) plt.show()
PTime和PReactions是数组的名称,依此类推。 这是上述代码的输出:
但我不想要这种类型的图表。我要多行表示不同的数组(不同的数据)。 我想要类似的结果:
最小工作示例:
import matplotlib.pyplot as plt import numpy as np a=np.linspace(0, 1, 10) b=np.linspace(0, 2, 10) c=np.linspace(0, 3, 10) d=np.linspace(0, 4, 10) plt.plot(b,a) plt.plot(c,a) plt.plot(d,a) plt.show()
给你:
您的数据以错误的顺序显示。它必须是X, Y:
X, Y
plt.plot(PReactions, PTime) plt.plot(NYReactions, NYTime) plt.plot(LReactions, LTime) plt.plot(SFReactions, SFTime) plt.show()
最小工作示例:
给你:
您的数据以错误的顺序显示。它必须是
X, Y
:相关问题 更多 >
编程相关推荐