Skip to content

Commit

Permalink
add 'ext' option to MatplotlibPlotter
Browse files Browse the repository at this point in the history
this option sets the extension (and therefore the format) of saved
pictures. If not set, the default is 'png'.
  • Loading branch information
skuschel committed Dec 14, 2014
1 parent fd4093f commit 6c50b62
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions postpic/plotting/plotter_matplotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ class MatplotlibPlotter(object):
'alpha': ((0, 1, 1), (0.5, 0, 0), (1, 1, 1))}
symmap = LinearSegmentedColormap('EField', efieldcdict, 1024)

def __init__(self, reader, outdir='./', autosave=False, project=None):
def __init__(self, reader, outdir='./', autosave=False, project=None, ext='png'):
self._ext = ext
self.autosave = autosave
self.reader = reader
self.outdir = outdir
Expand All @@ -61,7 +62,9 @@ def __len__(self):
def project(self):
return self._project if self._project else ''

def savename(self, key, ext='.png'):
def savename(self, key, ext=None):
if not ext:
ext = self._ext
name = self.project + '_' + self.reader.name + \
'_' + str(len(self._savenamesused)) + '_' + key
name = name.replace('/', '_').replace(' ', '')
Expand All @@ -73,7 +76,7 @@ def savename(self, key, ext='.png'):
name = nametmp % i
self._savenamesused.append(name)
# print name
return name + ext
return name + '.' + ext

def lastsavename(self):
'''
Expand Down

0 comments on commit 6c50b62

Please sign in to comment.