title: How to get data from matplotlib bar chart
body: <p>How does one retrieve data programmatically from a matplotlib bar chart? I can do it for a matplotlib line chart as follows, so maybe I'm fairly close:</p>
  <pre><code>import matplotlib.pyplot as plt
  
  plt.plot([1,2,3],[4,5,6])
  
  axis = plt.gca()
  line = axis.lines[0]
  x_plot, y_plot = line.get_xydata().T
  print(&quot;x_plot: &quot;, x_plot)
  print(&quot;y_plot: &quot;, y_plot)
  </code></pre>
  <p>for a bar chart, however, there are no lines, and I'm unclear what the equivalent object is:</p>
  <pre><code>plt.bar([1,2,3], [4,5,6])
  axis = plt.gca()
  ???
  </code></pre>
  <p>FWIW, here are a couple of related postings (that don't go into bar charts):</p>
  <ul>
  <li><a href="https://stackoverflow.com/questions/8938449/how-to-extract-data-from-matplotlib-plot#8939010">How to extract data from matplotlib plot</a></li>
  <li><a href="https://stackoverflow.com/questions/20130768/retrieve-xy-data-from-matplotlib-figure">Retrieve XY data from matplotlib figure</a></li>
  </ul>