title: How to determine screen size in matplotlib
body: <p>I am looking for a general way to get the screen size in pixels using matplotlib with any interactive backend (e.g. TkAgg, Qt4Agg, or macosx).</p>
  
  <p>I am trying to write a function which can open a window at a set of standard locations on the screen like e.g. the right half of the screen, or the top-right corner.</p>
  
  <p>I wrote a working solution <a href="https://stackoverflow.com/a/29039755/3753826">here</a>, copied below, but it requires one to use full_screen_toggle() (as suggested <a href="https://stackoverflow.com/a/27791519/3753826">here</a>) to create a full-screen window to measure its size.</p>
  
  <p>I am looking for a way to get the screen size without creating a full-screen window and then changing its size.</p>
  
  <pre><code>import matplotlib.pyplot as plt
  
  def move_figure(position="top-right"):
      '''
      Move and resize a window to a set of standard positions on the screen.
      Possible positions are:
      top, bottom, left, right, top-left, top-right, bottom-left, bottom-right
      '''
  
      mgr = plt.get_current_fig_manager()
      mgr.full_screen_toggle()  # primitive but works to get screen size
      py = mgr.canvas.height()
      px = mgr.canvas.width()
  
      d = 10  # width of the window border in pixels
      if position == "top":
          # x-top-left-corner, y-top-left-corner, x-width, y-width (in pixels)
          mgr.window.setGeometry(d, 4*d, px - 2*d, py/2 - 4*d)
      elif position == "bottom":
          mgr.window.setGeometry(d, py/2 + 5*d, px - 2*d, py/2 - 4*d)
      elif position == "left":
          mgr.window.setGeometry(d, 4*d, px/2 - 2*d, py - 4*d)
      elif position == "right":
          mgr.window.setGeometry(px/2 + d, 4*d, px/2 - 2*d, py - 4*d)
      elif position == "top-left":
          mgr.window.setGeometry(d, 4*d, px/2 - 2*d, py/2 - 4*d)
      elif position == "top-right":
          mgr.window.setGeometry(px/2 + d, 4*d, px/2 - 2*d, py/2 - 4*d)
      elif position == "bottom-left":
          mgr.window.setGeometry(d, py/2 + 5*d, px/2 - 2*d, py/2 - 4*d)
      elif position == "bottom-right":
          mgr.window.setGeometry(px/2 + d, py/2 + 5*d, px/2 - 2*d, py/2 - 4*d)
  
  
  if __name__ == '__main__':
  
      # Usage example for move_figure()
  
      plt.figure(1)
      plt.plot([0, 1])
      move_figure("top-right")
  
      plt.figure(2)
      plt.plot([0, 3])
      move_figure("bottom-right")
  </code></pre>