elexhobby
elexhobby

Reputation: 2668

Matplotlib Line2D unexpected behavior

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

Upvotes: 0

Views: 111

Answers (1)

tmdavison
tmdavison

Reputation: 69116

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

Upvotes: 1

Related Questions