Skip to content

Commit d916da6

Browse files
committed
Temporarily set DISPLAY environment variable if not set before saving. See Issue 17.
1 parent be3e7eb commit d916da6

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

PlotLayout.py

+11
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import matplotlib
33
from matplotlib import pyplot
44
import sys
5+
import os
56

67
from Utils import getGoldenRatioDimensions
78

@@ -252,6 +253,16 @@ def plot(self):
252253

253254
def save(self, filename):
254255
print "Saving %s ..." % filename
256+
257+
tempDisplayHack = False
258+
259+
if "DISPLAY" not in os.environ:
260+
tempDisplayHack = True
261+
os.environ["DISPLAY"] = ":0.0"
262+
255263
self.__doPlot()
256264
pylab.savefig(filename)
257265
pylab.clf()
266+
267+
if tempDisplayHack == True:
268+
del os.environ["DISPLAY"]

0 commit comments

Comments
 (0)