【发布时间】:2016-04-14 16:46:45
【问题描述】:
我有这段代码可以标出要点:
import matplotlib.pyplot as plot
from matplotlib import pyplot
all_data = [[1,10],[2,10],[3,10],[4,10],[5,10],[3,1],[3,2],[3,3],[3,4],[3,5]]
x = []
y = []
for i in xrange(len(all_data)):
x.append(all_data[i][0])
y.append(all_data[i][1])
plot.scatter(x,y)
pyplot.show()
但我希望所有可能的行看起来像这样:
我已经尝试过 matplotlib 路径,但它对我来说效果不佳。
【问题讨论】:
-
不确定 matplotlib 问题,但您可以使用
x, y = zip(*all_data)而不是循环(如果您需要列表而不是元组,则可以使用x, y = map(list, zip(*all_data)))来节省一些代码行。
标签: python matplotlib