python pyplot连接点 [英] python pyplot connecting points

查看:52
本文介绍了python pyplot连接点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下方法制作带有一组点的 pyplot 图:

I am making a pyplot graph with a set of points using:

    plt.plot([range(0,10)], [dictionary[key]],'bo')

这正确地绘制了我期望的点,但是我也希望在这些点之间画一条线.我找不到用pyplot做到这一点的方法,我认为这是微不足道的.

This correctly draws the points as I expect, however I also want a line to be drawn between these points. I can't find a way to do this with pyplot, I assume it's trivial.

有人可以解释我该怎么做吗?

Can someone explain how I can do this?

推荐答案

在你的情况下 [range(0,10)] 是一个列表列表.因此,您将绘制10个点而不是一条线.试试

In your case [range(0,10)] is a list of list. Hence, you are plotting 10 points instead of a line. Try

plt.plot(range(0,10), dictionary[key],'bo-')

这篇关于python pyplot连接点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆