title: How to clear matplotlib labels in legend?
body: <p>Is there a way to clear matplotlib labels inside a graph's legend? <a href="https://stackoverflow.com/questions/5735208/remove-the-legend-on-a-matplotlib-figure">This post</a> explains how to remove the legend itself, but the labels themselves still remain, and appear again if you plot a new figure. I tried the following code, but it does not work:</p>
  
  <pre><code>handles, labels = ax.get_legend_handles_labels()
  labels = []
  </code></pre>
  
  <p>EDIT: Here is an example</p>
  
  <pre><code>import matplotlib.pyplot as plt
  
  fig = plt.figure()
  ax = fig.gca()
  ax.scatter([1,2,3], [4,5,6], label = "a")
  legend = ax.legend()
  plt.show()
  legend.remove()
  handles, labels = ax.get_legend_handles_labels()
  print(labels)
  </code></pre>
  
  <p>Output: <code>["a"]</code></p>