I'm rendering some matplotlib plots to PDF using matplotlib.backends.backend_pdf. It works fine when I run it from my (Linux) computer, but if I ssh in to the computer from an external location and run the code, it fails with the following error message.
File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 343, in figure
**kwargs)
File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py", line 80, in new_figure_manager
window = Tk.Tk()
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1688, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable
The line in my code at which it fails is fig = matplotlib.pyplot.figure(figsize=(11.5,14.8)).
I assume this is something to do with it trying to find the display on which to render the plots, but my code never actually displays them. It only saves to PDF. Is there any way I can work around this issue to get the code to run properly?