|
39 | 39 | from matplotlib.cbook import iterable, is_string_like
|
40 | 40 | from matplotlib.compat import subprocess
|
41 | 41 | from matplotlib import verbose
|
42 |
| -from matplotlib import rcParams, rcParamsDefault |
| 42 | +from matplotlib import rcParams, rcParamsDefault, rc_context |
43 | 43 |
|
44 | 44 | # Process creation flag for subprocess to prevent it raising a terminal
|
45 | 45 | # window. See for example:
|
@@ -801,17 +801,26 @@ def save(self, filename, writer=None, fps=None, dpi=None, codec=None,
|
801 | 801 | # frame information to be saved later.
|
802 | 802 | # TODO: Right now, after closing the figure, saving a movie won't work
|
803 | 803 | # since GUI widgets are gone. Either need to remove extra code to
|
804 |
| - # allow for this non-existant use case or find a way to make it work. |
805 |
| - with writer.saving(self._fig, filename, dpi): |
806 |
| - for anim in all_anim: |
807 |
| - # Clear the initial frame |
808 |
| - anim._init_draw() |
809 |
| - for data in zip(*[a.new_saved_frame_seq() |
810 |
| - for a in all_anim]): |
811 |
| - for anim, d in zip(all_anim, data): |
812 |
| - # TODO: Need to see if turning off blit is really necessary |
813 |
| - anim._draw_next_frame(d, blit=False) |
814 |
| - writer.grab_frame(**savefig_kwargs) |
| 804 | + # allow for this non-existent use case or find a way to make it work. |
| 805 | + with rc_context(): |
| 806 | + # See above about bbox_inches savefig kwarg |
| 807 | + if (not writer.frame_size_can_vary and |
| 808 | + rcParams['savefig.bbox'] == 'tight'): |
| 809 | + verbose.report("Disabling savefig.bbox = 'tight', as it is " |
| 810 | + "not supported by " |
| 811 | + "{0}.".format(writer.__class__.__name__), |
| 812 | + level='helpful') |
| 813 | + rcParams['savefig.bbox'] = None |
| 814 | + with writer.saving(self._fig, filename, dpi): |
| 815 | + for anim in all_anim: |
| 816 | + # Clear the initial frame |
| 817 | + anim._init_draw() |
| 818 | + for data in zip(*[a.new_saved_frame_seq() |
| 819 | + for a in all_anim]): |
| 820 | + for anim, d in zip(all_anim, data): |
| 821 | + # TODO: See if turning off blit is really necessary |
| 822 | + anim._draw_next_frame(d, blit=False) |
| 823 | + writer.grab_frame(**savefig_kwargs) |
815 | 824 |
|
816 | 825 | # Reconnect signal for first draw if necessary
|
817 | 826 | if reconnect_first_draw:
|
|
0 commit comments