title: How to update the legend from matplotlib toolbar
body: <p>I am defining a matplotlib plot for a given data. once the plot is displayed, I am trying to change some line property using navigation tool bar edit option. </p>
  
  <p>When I make change say example solid line to dashdotted, the update get reflected on the lines, but the legends are not updated. </p>
  
  <p>How can I capture this event when the apply button is clicked, so i can use this to refresh the legend. At the moment I am capturing a pick_event as a signal to refresh the legends.</p>
  
  <pre><code>import numpy as np
  import matplotlib.pyplot as plt
  import matplotlib
  matplotlib.use('Qt4Agg')
  
  
  x=np.linspace(0,100,100)
  y=np.linspace(100,200,100)
  plt.plot(x,y,label='test')
  plt.legend()
  ax.legend()
  plt.show()
  #optional code
  def on_press(event):
      lines, labels = ax.get_legend_handles_labels()
      ax.legend(lines, labels, loc=0)
      fig.canvas.draw()
  
  cid = fig.canvas.mpl_connect('pick_event', on_press)
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/rLT6M.png" alt="Plot image from the above code">
  <img src="https://i.stack.imgur.com/61Ro3.png" alt="Plot Image showing modifying line type">
  <img src="https://i.stack.imgur.com/zdWD0.png" alt="Plot Image showing the legend is not modified"></p>