pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/matplotlib/matplotlib/pull/31078/files

://github.githubassets.com/assets/primer-primitives-10bf9dd67e3d70bd.css" /> Backport PR #31075 on branch v3.10.x (Fix remove method for figure title and xy-labels) by meeseeksmachine · Pull Request #31078 · matplotlib/matplotlib · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,17 @@ def _suplabels(self, t, info, **kwargs):
else:
suplab = self.text(x, y, t, **kwargs)
setattr(self, info['name'], suplab)
suplab._remove_method = functools.partial(self._remove_suplabel,
name=info['name'])

suplab._autopos = autopos
self.stale = True
return suplab

def _remove_suplabel(self, label, name):
self.texts.remove(label)
setattr(self, name, None)

@_docstring.Substitution(x0=0.5, y0=0.98, name='super title', ha='center',
va='top', rc='title')
@_docstring.copy(_suplabels)
Expand Down
22 changes: 22 additions & 0 deletions lib/matplotlib/tests/test_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,28 @@ def test_get_suptitle_supxlabel_supylabel():
assert fig.get_supylabel() == 'supylabel'


def test_remove_suptitle_supxlabel_supylabel():
fig = plt.figure()

title = fig.suptitle('suptitle')
xlabel = fig.supxlabel('supxlabel')
ylabel = fig.supylabel('supylabel')

assert len(fig.texts) == 3
assert fig._suptitle is not None
assert fig._supxlabel is not None
assert fig._supylabel is not None

title.remove()
assert fig._suptitle is None
xlabel.remove()
assert fig._supxlabel is None
ylabel.remove()
assert fig._supylabel is None

assert not fig.texts


@image_comparison(['alpha_background'],
# only test png and svg. The PDF output appears correct,
# but Ghostscript does not preserve the background color.
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy