0

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()

enter image description here

2
  • 1
    have you had a look in the docs? You actually draw a line from (-2.33, 4.33) to (10,-10), as described in the docstring. Commented Jun 12, 2015 at 21:39
  • Silly of me, sorry. I read the docs, but somehow overlooked this. Commented Jun 12, 2015 at 21:41

1 Answer 1

1

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))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.