Skip to content

Commit 3026bbd

Browse files
committed
Set default dpi to figure.dpi for MovieWriter classes.
1 parent 0cab7c6 commit 3026bbd

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

lib/matplotlib/animation.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,17 +155,17 @@ class AbstractMovieWriter(six.with_metaclass(abc.ABCMeta)):
155155
'''
156156

157157
@abc.abstractmethod
158-
def setup(self, fig, outfile, dpi):
158+
def setup(self, fig, outfile, dpi=None):
159159
'''
160160
Perform setup for writing the movie file.
161161
162162
fig: `matplotlib.Figure` instance
163163
The figure object that contains the information for frames
164164
outfile: string
165165
The filename of the resulting movie file
166-
dpi: int
166+
dpi: int, optional
167167
The DPI (or resolution) for the file. This controls the size
168-
in pixels of the resulting movie file.
168+
in pixels of the resulting movie file. Default is fig.dpi.
169169
'''
170170

171171
@abc.abstractmethod
@@ -281,7 +281,7 @@ def _adjust_frame_size(self):
281281
verbose.report('frame size in pixels is %s x %s' % self.frame_size,
282282
level='debug')
283283

284-
def setup(self, fig, outfile, dpi):
284+
def setup(self, fig, outfile, dpi=None):
285285
'''
286286
Perform setup for writing the movie file.
287287
@@ -292,12 +292,14 @@ def setup(self, fig, outfile, dpi):
292292
The figure object that contains the information for frames
293293
outfile : string
294294
The filename of the resulting movie file
295-
dpi : int
295+
dpi : int, optional
296296
The DPI (or resolution) for the file. This controls the size
297-
in pixels of the resulting movie file.
297+
in pixels of the resulting movie file. Default is fig.dpi.
298298
'''
299299
self.outfile = outfile
300300
self.fig = fig
301+
if dpi is None:
302+
dpi = self.fig.dpi
301303
self.dpi = dpi
302304
self._adjust_frame_size()
303305

@@ -404,7 +406,8 @@ def __init__(self, *args, **kwargs):
404406
MovieWriter.__init__(self, *args, **kwargs)
405407
self.frame_format = rcParams['animation.frame_format']
406408

407-
def setup(self, fig, outfile, dpi, frame_prefix='_tmp', clear_temp=True):
409+
def setup(self, fig, outfile, dpi=None, frame_prefix='_tmp',
410+
clear_temp=True):
408411
'''Perform setup for writing the movie file.
409412
410413
Parameters
@@ -413,9 +416,10 @@ def setup(self, fig, outfile, dpi, frame_prefix='_tmp', clear_temp=True):
413416
The figure to grab the rendered frames from.
414417
outfile : str
415418
The filename of the resulting movie file.
416-
dpi : number
419+
dpi : number, optional
417420
The dpi of the output file. This, with the figure size,
418421
controls the size in pixels of the resulting movie file.
422+
Default is fig.dpi.
419423
frame_prefix : str, optional
420424
The filename prefix to use for temporary files. Defaults to
421425
'_tmp'.
@@ -427,6 +431,8 @@ def setup(self, fig, outfile, dpi, frame_prefix='_tmp', clear_temp=True):
427431
'''
428432
self.fig = fig
429433
self.outfile = outfile
434+
if dpi is None:
435+
dpi = self.fig.dpi
430436
self.dpi = dpi
431437
self._adjust_frame_size()
432438

0 commit comments

Comments
 (0)