简体   繁体   English

如何在python图中连接点?

[英]How to connect points in python plot?

Wanted to connect points in matplotlib plot.below is the sample code. 想要连接matplotlib图中的点。下面是示例代码。 each element in list has timestamp and argv. 列表中的每个元素都有时间戳和argv。 Please educate.Code below plots correctly but do not connect points between different elements of list even if I have mentioned 'rs-'. 请教育以下代码可以正确绘制,但是即使我提到了'rs-',也不要在列表的不同元素之间连接点。

for a in list:
      plt.plot(a.time,a.argv,'rs-')

If you want your points connected, you need to plot them all in one call. 如果要连接点,则需要在一次调用中将它们全部绘制出来。 Create a list of the points you want to plot, then call plt.plot 创建要绘制的点的列表,然后调用plt.plot

points = [(a.time, a.argv) for a in l]
plt.plot(points, "rs-")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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