Matplotlib Line2D 意外行为 [英] Matplotlib Line2D unexpected behavior

查看:37
本文介绍了Matplotlib Line2D 意外行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个最低限度的工作示例.我希望下面的代码从 (-2.33,10) 到 (4.33,-10) 画一条线,但我得到的线完全不同.怎么了?

This is a minimum working example. I expect the following code to draw a line from (-2.33,10) to (4.33,-10), but the line I get is totally different. What is wrong?

import matplotlib.pyplot as plt
import matplotlib

fig = plt.figure()
ax = fig.add_subplot(111)
ax.axis((-10,10,-10,10))
line = matplotlib.lines.Line2D((-2.33,10.0),(4.33,-10.0))
ax.add_line(line)
plt.show()

推荐答案

你已经给了 line2D (x1, y1), (x2, y2),但是你需要给它 (x1,x2),(y1,y2)

You have given line2D (x1, y1), (x2, y2), but you need to give it (x1, x2), (y1, y2)

line = matplotlib.lines.Line2D((-2.33,4.33),(10,-10.0))

这篇关于Matplotlib Line2D 意外行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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