How to use python to draw multiple lists or arrays of data in the same picture

Upper code:

from matplotlib import pyplot as plt

x = [1,2,3]
y = [[1,2,3],[4,5,6],[7,8,9]]

fig= plt.figure(figsize=(15,5))

plt.xlabel("X-axis")
plt.ylabel("Y-axis")
plt.title("A test graph")

for i in range(len(y)):
       plt.plot(x,y[i],label = 'id %s'%i)


plt.legend()
plt.show()

 

result:

 

Welcome to follow AI Daniel:

For more professional articles related to artificial intelligence, search on WeChat: robot-learner, or scan the QR code

Guess you like

Origin blog.csdn.net/robot_learner/article/details/105067307