I have run 3 Python scripts and each of them generated one curve in the plot.
Each curve is made up of hundreds of small line segments.
Thus, each curve is drawn by a series of plot()
instead of one.
But all these plot()
share the same parameters (e.g. the color, style of one curve is consistent).
Thus, I think it is still possible to easily remove all the segments drawn by particular one script.
I find that the curve generated by the most-recently-run script is erroneous. Therefore, I wish to remove it. But at the same time, I cannot afford to just close the window and redraw everything. I wish to keep all the other curves there.
How may I do that?
Updates: Plotting Codes
for i, position in enumerate(positions):
if i == 0:
plt.plot([0,0], [0,0], color=COLOR, label=LABEL)
else:
plt.plot([positions[i - 1][0], position[0]], [positions[i - 1][1], position[1]], STYLE, color=COLOR)
#plt.plot([min(np.array(positions)[:,0]), max(np.array(positions)[:,0])], [0,0], color='k', label='East') # West-East
#plt.plot([0,0], [min(np.array(positions)[:,1]), max(np.array(positions)[:,1])], color='k', label='North') # South-North
plt.gca().set_aspect('equal', adjustable='box')
plt.title('Circle Through the Lobby 3 times', fontsize=18)
plt.xlabel('x (m)', fontsize=16)
plt.ylabel('y (m)', fontsize=16)
plt.legend(loc='center left', bbox_to_anchor=(1, 0.5))
plt.draw()