如何使用matplotlib在同一图上绘制多个轨迹

时间:2020-01-01 05:55:28

标签: python matplotlib

对于多条轨迹,我具有轨迹中每个点的二维坐标。我想使用python(最好是matplotlib)在一个绘图上绘制所有这些轨迹。我想要轨迹的时序图,如示例图中的左图所示。我在Internet上找到的样本图是enter image description here

1 个答案:

答案 0 :(得分:0)

使用 pyplot.plot()方法。您可以在同一图形上绘制任意数量的轨迹。

@XmlElement

对于3D图:

from matplotlib import pyplot

x = range(12)
y1 = range(12)
y2 = [i**2 for i in x]
# y3,y4,...yn

pyplot.plot(x,y1)
pyplot.plot(x,y2)
pyplot.show()