Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cfl() doesn't clear gcf()._suptitle #2525

Closed
brorfred opened this issue Oct 16, 2013 · 4 comments
Closed

cfl() doesn't clear gcf()._suptitle #2525

brorfred opened this issue Oct 16, 2013 · 4 comments

Comments

@brorfred
Copy link

Issue

suptitle doesn't replace the text if the figure is cleared with clf.

Work:

import pylab as plt
plt.figure()
plt.suptitle('KK')
plt.suptitle('HH')

Doesn't work:

import pylab as plt
plt.figure()
plt.suptitle('KK')
plt.clf()
plt.suptitle('KK')
plt.suptitle('HH')

Solution?

add self._suptitle = None to figure.clf()

Thanks!!!

/Bror Jonsson

@pelson
Copy link
Member

pelson commented Oct 18, 2013

Sounds reasonable. Do you fancy trying to submit a PR with the necessary change and a test to ensure that this remains fixed?

Thanks!

@tacaswell
Copy link
Member

@brorfred Are you interested in putting together the fix + a test?

Should be linked to #1747

@cimarronm
Copy link
Contributor

Likewise, even without the clf(), you have an issue if you call fig.suptitle() >2 times
The following code will show both "BB" and "CC" being rendered on the figure (in fact there are three text artists being rendered: two with "BB" and one with "CC")

import pylab as plt
plt.figure()
plt.suptitle('AA')
plt.suptitle('BB')
plt.suptitle('CC') 

The larger issue is that each time plt.suptitle is called it creates an endless amount of text artists as you can see with the following sample code

import pylab as plt
fig = plt.figure()
print(fig.texts)
plt.suptitle('AA')
plt.suptitle('BB')
plt.suptitle('CC')
plt.suptitle('DD')
print(fig.texts)

You will see that 4 text artists are added with fig._suptitle only point to one of them.

cimarronm added a commit to cimarronm/matplotlib that referenced this issue Jan 8, 2014
…ixes a bug

where suptitle endlessly adds text artists to the figure
@pelson pelson closed this as completed Jan 9, 2014
@pelson
Copy link
Member

pelson commented Jan 9, 2014

Closed by #2711

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants