简体   繁体   English

如何在 matplotlib plot 中画几条线?

[英]How can I draw several lines in a matplotlib plot?

I would also have a contour and vector field on the plot, and I would like to draw several lines on it.我还想在 plot 上有一个轮廓和矢量场,我想在上面画几条线。 But when I used ax.plot for several times, only one line is shown.但是当我多次使用 ax.plot 时,只显示了一行。

like this像这样

ax.plot([-1,-1], [1,1],linewidth=3,c='y')
import matplotlib.pyplot as plt

fig = plt.figure(figsize = (10,10))
ax = fig.add_subplot(111)
x1 = [10,20,30]
y1 = [20,40,10]
#plot the first line
ax.plot(x1, y1)

x2 = [10,20,30]
y2 = [40,10,30]
#plot the second line
ax.plot(x2, y2)

plt.show()

This piece of code should be able to produce multiple lines in the same axes这段代码应该能够在同一轴上产生多条线

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM