在python matplotlib中绘制(x,y)坐标列表(Plotting a list of (x, y) coordinates in python matplotlib)
我有一个对(a, b)的列表,我想用python中的matplotlib作为实际的xy坐标绘制。 目前,它正在制作两个绘图,其中列表的索引给出x坐标,第一个图的y值是成对的a s,第二个图的y值是成对的b 。
为了澄清,我的数据如下所示: li = [(a,b), (c,d), ... , (t, u)]我想做一个只需调用plt.plot()不正确。 如果我不需要一个单行我可以简单地做:
xs = [x[0] for x in li]
ys = [x[1] for x in li]
plt.plot(xs, ys)
如何将matplotlib绘制为xy坐标?
感谢所有的帮助!
I have a list of pairs (a, b) that I would like to plot with matplotlib in python as actual x-y coordinates. Currently, it is making two plots, where the index of the list gives the x-coordinate, and the first plot's y values are the as in the pairs and the second plot's y values are the bs in the pairs.
To clarify, my data looks like this: li = [(a,b), (c,d), ... , (t, u)] I want to do a one-liner that just calls plt.plot() incorrect. If I didn't require a one-liner I could trivially do:
xs = [x[0] for x in li]
ys = [x[1] for x in li]
plt.plot(xs, ys)
How can I get matplotlib to plot these pairs as x-y coordinates?
Thanks for all the help!