我不明白为什么 matplotlib 要创建另一行?
import matplotlib.pyplot as plt
xy1 = []
x1 = 0
while x1 < 10:
x1 = x1 + 1
y1 = x1**2
xy1.append([x1,y1])
plt.plot(xy1)
print(xy1)
plt.show()
最佳答案
来自documentation ,您可以看到 plt.plot
可以绘制多个图:
If x and/or y is 2-dimensional, then the corresponding columns will be plotted.
您的数据如下所示:
[[1, 1], [2, 4], [3, 9], [4, 16], [5, 25], [6, 36], [7, 49], [8, 64], [9, 81], [10, 100]]
关于python - 为什么 matplotlib 中显示两条线?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33272825/