title: Matplotlib text dimensions
body: <p>Is it possible to determine the dimensions of a matplotlib text object? How can I find the width and height in pixels?</p>
  
  <p>Thanks</p>
  
  <p><strong>Edit</strong>: I think I figured out a way to do this. I've included an example below.</p>
  
  <pre><code>import matplotlib as plt
  
  f = plt.figure()
  r = f.canvas.get_renderer()
  t = plt.text(0.5, 0.5, 'test')
  
  bb = t.get_window_extent(renderer=r)
  width = bb.width
  height = bb.height
  </code></pre>