RuntimeError: could not open display

I should add that we were both ssh'd into a Linux machine,

    > he from Windows and I from Linux. So his DISPLAY was not
    > set and mine was. When he ran the script it failed for him,
    > but worked for me, even though the script only did a savefig
    > and never tried to actually show() anything to a screen. Is
    > that expected behavior?

If you don't use the matplotlib.use directive, matplotlib will try and
load its default backend from the rc file
(; if you haven't customized
this on linux it is GTKAgg. My guess is that this is what is causing
your problem. You have two choices in addition to the use directive:

  1) change the default backend to a non-GUI backend in the rc file,
     eg "backend : PS". Copy the rc file to your HOME directory (or
     working directory) and edit it.

  2) use a command line arg to force the backend

     > python -dPS

Hope this helps,