You are using plt.plot()
incorrectly.
What plt.plot()
does is Plot y versus x as lines and/or markers.
In the docs, you can see that since the call plot(AB)
has only 1 argument, AB
is being passed as the Y values.
The X value, in this case, is the index of the elements in the array of Y values.
It is the same as calling plt.plot([(1,0),(3,4)])
. Since you have 2 tuples of Y values, you will get 2 different lines: [(0,1),(1,3)]
and [(0,0),(1,4)]
. (Notice the x values are 0 and 1, the index of the corresponding tuple of Y value.)
You can see in the screenshot of the output, that in the first case you also plot 2 lines. But in the case of these specific values, plt.plot([(0,0),(1,1)])
will plot the same line twice.
If you just want to graph a line from point A to point B, you can use:
A = Point(1,0)
B = Point(3,4)
AB = LineString([A,B])
plt.plot(*AB.xy)
plt.show()