Dec-17-2017, 04:34 PM
Hi. I'm learning matplotlib and have an issue. I have a scatter plot working perfectly. I'm trying to draw lines between two points but it seems to be on a completely different axis scale. Why isn't the line being drawn between the two points specified?
import matplotlib.pyplot as plt points = [] points.append((1, 2, 10,2)) points.append((10, 2, 1,200)) points.append((1, 200, 799,799)) points.append((150, 702, 142,221)) points.append((799, 799, 400, 400)) points.append((142, 221, 799, 799)) points.append((11, 562, 142, 221)) points.append((145, 255, 11, 562)) points.append((170, 702, 145, 255)) points.append((14, 52, 170, 702)) points.append((314, 35, 14, 52)) points.append((414, 52, 314, 352)) points.append((14, 452, 414, 52)) points.append((14, 552, 14, 452)) points.append((514, 52, 14, 552)) points.append((14, 652, 514, 52)) points.append((614, 52, 14, 652)) points.append((714, 752, 614, 52)) points.append((750, 712, 714, 752)) points.append((703, 742, 750, 712)) points.append((714, 772, 703, 742)) points.append((400,400, 714, 772)) gridpointsX = [200,200,200,400,400,400,600,600,600] gridpointsY = [200,400,600,200,400,600,200,400,600] xp = [] yp = [] for point in points: xp.append(point[0]) yp.append(point[1]) # plt.plot([point[0], point[1]], [point[2], point[3]]) plt.plot([400,400], [714,772]) # plt.grid(True, markevery=200) plt.plot(xp, yp, 'bo') plt.plot(gridpointsX, gridpointsY, "+", ms=10, zorder=-1, lw=.2) plt.axis([0,800,0,800]) plt.show() # savefig('plotted.png')