Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c30129b

Browse filesBrowse files
authored
Merge pull request #16980 from anntzer/draw_disabled
Correctly disable more drawing methods in tight_bboxing renderer.
2 parents 98560a8 + 001afaf commit c30129b
Copy full SHA for c30129b

File tree

2 files changed

+9
-2
lines changed
Filter options

2 files changed

+9
-2
lines changed

‎lib/matplotlib/backend_bases.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backend_bases.py
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,7 +1500,7 @@ def _get_renderer(figure, print_method, *, draw_disabled=False):
15001500
Get the renderer that would be used to save a `~.Figure`, and cache it on
15011501
the figure.
15021502
1503-
If *draw_disabled* is True, additionally replace draw_foo methods on
1503+
If *draw_disabled* is True, additionally replace drawing methods on
15041504
*renderer* by no-ops. This is used by the tight-bbox-saving renderer,
15051505
which needs to walk through the artist tree to compute the tight-bbox, but
15061506
for which the output file may be closed early.
@@ -1521,7 +1521,8 @@ def _draw(renderer): raise Done(renderer)
15211521

15221522
if draw_disabled:
15231523
for meth_name in dir(RendererBase):
1524-
if meth_name.startswith("draw_"):
1524+
if (meth_name.startswith("draw_")
1525+
or meth_name in ["open_group", "close_group"]):
15251526
setattr(renderer, meth_name, lambda *args, **kwargs: None)
15261527

15271528
return renderer

‎lib/matplotlib/tests/test_backend_svg.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_backend_svg.py
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,3 +207,9 @@ def include(gid, obj):
207207
for gid, obj in gdic.items():
208208
if include(gid, obj):
209209
assert gid in buf
210+
211+
212+
def test_savefig_tight():
213+
# Check that the draw-disabled renderer correctly disables open/close_group
214+
# as well.
215+
plt.savefig(BytesIO(), format="svgz", bbox_inches="tight")

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.