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 c341652

Browse filesBrowse files
QuLogicmeeseeksmachine
authored andcommitted
Backport PR #16980: Correctly disable more drawing methods in tight_bboxing renderer.
1 parent 39e5589 commit c341652
Copy full SHA for c341652

File tree

Expand file treeCollapse file tree

2 files changed

+9
-2
lines changed
Filter options
Expand file treeCollapse file tree

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
@@ -1521,7 +1521,7 @@ def _get_renderer(figure, print_method, *, draw_disabled=False):
15211521
Get the renderer that would be used to save a `~.Figure`, and cache it on
15221522
the figure.
15231523
1524-
If *draw_disabled* is True, additionally replace draw_foo methods on
1524+
If *draw_disabled* is True, additionally replace drawing methods on
15251525
*renderer* by no-ops. This is used by the tight-bbox-saving renderer,
15261526
which needs to walk through the artist tree to compute the tight-bbox, but
15271527
for which the output file may be closed early.
@@ -1542,7 +1542,8 @@ def _draw(renderer): raise Done(renderer)
15421542

15431543
if draw_disabled:
15441544
for meth_name in dir(RendererBase):
1545-
if meth_name.startswith("draw_"):
1545+
if (meth_name.startswith("draw_")
1546+
or meth_name in ["open_group", "close_group"]):
15461547
setattr(renderer, meth_name, lambda *args, **kwargs: None)
15471548

15481549
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
@@ -205,3 +205,9 @@ def include(gid, obj):
205205
for gid, obj in gdic.items():
206206
if include(gid, obj):
207207
assert gid in buf
208+
209+
210+
def test_savefig_tight():
211+
# Check that the draw-disabled renderer correctly disables open/close_group
212+
# as well.
213+
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.