Update MovieWriter dpi default #8063

Merged
merged 2 commits into from Feb 16, 2017

Conversation

Projects
None yet
3 participants
Contributor

heath730 commented Feb 11, 2017

Adds default dpi=None argument to *MovieWriter classes, and uses figure.dpi as the default if dpi is None.

This is related to issue #7616. @tacaswell please advise if this approach is what you had in mind for resolving the issue.

I'm a new contributor and I wasn't exactly sure the best way to unit test a change like this. However, I created a test that calls setup with dpi as the default, and makes sure that dpi is set to the figure.dpi. I did not add a change log entry because it is such a small change, please let me know if I should.

lib/matplotlib/animation.py
@@ -165,7 +165,7 @@ def setup(self, fig, outfile, dpi):
The filename of the resulting movie file
dpi: int
The DPI (or resolution) for the file. This controls the size
- in pixels of the resulting movie file.
+ in pixels of the resulting movie file. Default is figure.dpi.
@tacaswell

tacaswell Feb 11, 2017

Owner

The docstring on this needs , optional added

@tacaswell

tacaswell Feb 11, 2017

Owner

probably on all of the docstrings actually.

Contributor

heath730 commented Feb 11, 2017

@tacaswell I just updated the docstrings.

I just noticed that in Animate.save() has dpi=None default to rcParam['savefig.dpi'], and only if this is 'figure' it is set to figure.dpi. Should I use that behavior instead of setting None to figure.dpi?

Owner

tacaswell commented Feb 11, 2017

On one hand what you have here is simpler and does not depend on global state, on the other hand reaching out to rcParams['savefig.dpi'] is more consistent with savefig and Animation.save.

I am leaning towards not defaulting to rcParams['savefig.dpi']. This is a lower level interface (most users should be using Animation.save which is why this was a required argument before) and is being used by sophisticated users are are rolling their own version of save. Coupling into our global state starts to be an annoying detail to work around rather than a helpful default. It would not take much to convince me I am wrong on this and it should look at 'savefig.dpi'.

tacaswell added this to the 2.1 (next point release) milestone Feb 11, 2017

tacaswell changed the title from Update MovieWriter dpi default to [MRG+1] Update MovieWriter dpi default Feb 11, 2017

@dopplershift

I'm 👍 on the change--just the question about the docs.

lib/matplotlib/animation.py
The DPI (or resolution) for the file. This controls the size
- in pixels of the resulting movie file.
+ in pixels of the resulting movie file. Default is figure.dpi.
@dopplershift

dopplershift Feb 15, 2017

Contributor

Should figure.dpi be fig.dpi since fig is the name of the argument?

lib/matplotlib/animation.py
The DPI (or resolution) for the file. This controls the size
- in pixels of the resulting movie file.
+ in pixels of the resulting movie file. Default is figure.dpi.
@dopplershift

dopplershift Feb 15, 2017

Contributor

Here too?

lib/matplotlib/animation.py
The dpi of the output file. This, with the figure size,
controls the size in pixels of the resulting movie file.
+ Default is figure.dpi.
@dopplershift

dopplershift Feb 15, 2017

Contributor

And here?

Contributor

heath730 commented Feb 16, 2017

@tacaswell @dopplershift Thanks, I updated in (c2aac89). Let me know if should rebase this on master/squash some of these commits to something cleaner.

Contributor

dopplershift commented Feb 16, 2017

If it's not a lot of effort, I'd prefer to see this squashed down a bit.

heath730 added some commits Feb 11, 2017

@heath730 heath730 Set default dpi to figure.dpi for MovieWriter classes. 3026bbd
@heath730 heath730 Add test for setup dpi default.
e0c002c
Contributor

heath730 commented Feb 16, 2017

@dopplershift I squashed all the lints/nits into the original commit so it looks like it never happened. I also rebased on the current master because I was a few commits behind.

@dopplershift

Pending one last run of CI.

NelleV changed the title from [MRG+1] Update MovieWriter dpi default to [MRG+2] Update MovieWriter dpi default Feb 16, 2017

@dopplershift dopplershift merged commit f697e8c into matplotlib:master Feb 16, 2017

4 checks passed

codecov/patch 95% of diff hit (target 80%)
Details
codecov/project/library 62.22% (+<.01%) compared to 0cab7c6
Details
codecov/project/tests 97.94% (target 97.7%)
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

dopplershift changed the title from [MRG+2] Update MovieWriter dpi default to Update MovieWriter dpi default Feb 16, 2017

Contributor

dopplershift commented Feb 16, 2017

Thanks @heath730 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment