简体   繁体   中英

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. But when I used ax.plot for several times, only one line is shown.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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