I wonder if it is possible to update a parameter such as the line color of an already plotted graph that doesn't wrap on destroying the graph and creating another one.
Example: I plot a graph then I create a few horizontal green lines on it by clicking. Now I want to change the blue main line of the graph to the color red without losing the horizontal green lines that were created.
Something like:
import matplotlib.pyplot as plt
c = None
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot([1,2,3],[1,2,3], color = c)
def onclick(event):
plt.ion()
plt.hlines(event.ydata,event.xdata-0.1,event.xdata+0.1,
colors='green',linestyle='solid')
cid = fig.canvas.mpl_connect('button_press_event', onclick)
def change_color():
c = 'r'
# ???
plt.show()
change_color() # running this function will update the plot line color to red