使用Line2D在python中绘制线

使用Line2D在python中绘制线,第1张

使用Line2D在python中绘制线

您应该将线添加绘图中,然后显示它:

In [13]: import matplotlib.pyplot as pltIn [15]: from matplotlib.lines import Line2DIn [16]: fig = plt.figure()In [17]: ax = fig.add_subplot(111)In [18]: x = [10,24,23,23,3]In [19]: y = [12,2,3,4,2]In [20]: line = Line2D(x, y)In [21]: ax.add_line(line)Out[21]: <matplotlib.lines.Line2D at 0x7f4c10732f60>In [22]: ax.set_xlim(min(x), max(x))Out[22]: (3, 24)In [23]: ax.set_ylim(min(y), max(y))Out[23]: (2, 12)In [24]: plt.show()

结果:



欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5601882.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-15
下一篇 2022-12-15

发表评论

登录后才能评论

评论列表(0条)

保存