title: Problem running python/matplotlib in background after ending ssh session
body: <p>I have to VPN and then ssh from home to my work server and want to run a python script in the background, then log out of the ssh session. My script makes several histogram plots using matplotlib, and as long as I keep the connection open everything is fine, but if I log out I keep getting an error message in the log file I created for the script.</p>
  
  <pre><code> File "/Home/eud/jmcohen/.local/lib/python2.5/site-packages/matplotlib/pyplot.py", line 2058, in loglog
      ax = gca()
    File "/Home/eud/jmcohen/.local/lib/python2.5/site-packages/matplotlib/pyplot.py", line 582, in gca
      ax =  gcf().gca(**kwargs)
    File "/Home/eud/jmcohen/.local/lib/python2.5/site-packages/matplotlib/pyplot.py", line 276, in gcf
      return figure()
    File "/Home/eud/jmcohen/.local/lib/python2.5/site-packages/matplotlib/pyplot.py", line 254, in figure
      **kwargs)
    File "/Home/eud/jmcohen/.local/lib/python2.5/site-packages/matplotlib/backends/backend_tkagg.py", line 90, in new_figure_manager
      window = Tk.Tk()
    File "/Home/eud/jmcohen/.local/lib/python2.5/lib-tk/Tkinter.py", line 1647, in __init__
      self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
  _tkinter.TclError: couldn't connect to display "localhost:10.0"
  </code></pre>
  
  <p>I'm assuming that it doesn't know where to create the figures I want since I close my X11 ssh session. If I'm logged in while the script is running I don't see any figures popping up (although that's because I don't have the show() command in my script), and I thought that python uses tkinter to display figures. The way that I'm creating the figures is,</p>
  
  <pre><code>loglog()
  hist(list,x)
  ylabel('y')
  xlabel('x')
  savefig('%s_hist.ps' %source.name)
  close()
  </code></pre>
  
  <p>The script requires some initial input, so the way I'm running it in the background is </p>
  
  <pre><code>python scriptToRun.py &lt;&lt; start&gt;&amp; logfile.log&amp;
  </code></pre>
  
  <p>Is there a way around this, or do I just have to stay ssh'd into my machine? </p>
  
  <p>Thanks.</p>