Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9610a50

Browse files
committed
"Fix" tight_layout for template backend.
We rely on print_foo actually walking through the Figure tree (which any non-trivial canvas should likely do...).
1 parent 8589fed commit 9610a50

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

lib/matplotlib/backend_bases.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,8 +1552,10 @@ def _draw(renderer): raise Done(renderer)
15521552
print_method(io.BytesIO(), dpi=figure.dpi)
15531553
except Done as exc:
15541554
renderer, = figure._cachedRenderer, = exc.args
1555-
1556-
return renderer
1555+
return renderer
1556+
else:
1557+
raise RuntimeError(f"{print_method} did not call Figure.draw, so "
1558+
f"no renderer is available")
15571559

15581560

15591561
def _is_non_interactive_terminal_ipython(ip):

lib/matplotlib/backends/backend_template.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ def print_foo(self, filename, *args, **kwargs):
208208
to their original values after this call, so you don't need to
209209
save and restore them.
210210
"""
211+
self.draw()
211212

212213
def get_default_filetype(self):
213214
return 'foo'

0 commit comments

Comments
 (0)