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

Already on GitHub? Sign in to your account

Fix suptitle #1663

Merged
merged 3 commits into from Jan 18, 2013

Conversation

Projects
None yet
5 participants
Member

dmcdougall commented Jan 15, 2013

New version of #1276 but which targets v1.2.x and includes a test.

If there's no feedback I'll merge this in a day or two. I'd at least like @NelleV to check PEP8-ness, if you wouldn't mind :)

@NelleV NelleV commented on the diff Jan 16, 2013

lib/matplotlib/tests/test_figure.py
@@ -65,6 +65,13 @@ def test_gca():
assert_true(fig.gca(projection='rectilinear') is ax1)
assert_true(fig.gca() is ax1)
@NelleV

NelleV Jan 16, 2013

Contributor

PEP8 compliance: you need two blank lines here.

@NelleV NelleV commented on the diff Jan 16, 2013

lib/matplotlib/tests/test_figure.py
@@ -65,6 +65,13 @@ def test_gca():
assert_true(fig.gca(projection='rectilinear') is ax1)
assert_true(fig.gca() is ax1)
+@image_comparison(baseline_images=['figure_suptitle'])
+def test_suptitle():
+ fig = plt.figure()
+ ax = fig.add_subplot(1, 1, 1)
+ fig.suptitle('hello', color='r')
+ fig.suptitle('title', color='g', rotation='30')
+
@NelleV

NelleV Jan 16, 2013

Contributor

And here too !

Contributor

NelleV commented Jan 16, 2013

I've underlined the two PEP8 problem. Else, the code looks good to me.

Member

dmcdougall commented Jan 16, 2013

Wooo! A legitimate test failure!

@pelson Do you have any idea why that pickle test is failing? Looks like that title in the pickle baseline image is a suptitle, but the kwargs are still being set just as they were before this change. Perhaps the addition of a self._suptitle variable affects how the figure object gets pickled.

Member

pelson commented Jan 16, 2013

@dmcdougall - I'll have a butchers tomorrow at this for you. Has the result image gained a suptitle that wasn't there before?

Member

dmcdougall commented Jan 16, 2013

@pelson Another travis downside: I can't access the failing image. I'll run the test locally and report back.

Member

dmcdougall commented Jan 16, 2013

@pelson The produced image doesn't have a suptitle. Will look into it.

Member

dmcdougall commented Jan 16, 2013

I've found the issue. Since the suptitle (a Text object) now persists in the Figure class, having remove_text=True in the image_comparison decorator for the test_pickle test removes the text when producing the resulting image.

There are a couple of ways to proceed:

  1. Remove remove_text=True, resulting in a persisting suptitle but potentially causing further failures because of text issues.

  2. Keep remove_text=True and remove the suptitle. There is an additional check inside test_pickle to ensure that figure labels are preserved on unpickling. Downside is a new baseline image has to be committed.

  3. Don't merge this pull request.

I think 3) is overly harsh. I'd prefer to execute option 2), but if there is a consensus for 1), then I'm fine with that too.

Member

WeatherGod commented Jan 16, 2013

I am +1 on option 2.

Owner

mdboom commented Jan 16, 2013

Ditto for option 2.

Member

dmcdougall commented Jan 16, 2013

Done.

@pelson pelson and 1 other commented on an outdated diff Jan 17, 2013

lib/matplotlib/figure.py
@@ -491,8 +492,10 @@ def suptitle(self, t, **kwargs):
if ('verticalalignment' not in kwargs) and ('va' not in kwargs):
kwargs['verticalalignment'] = 'top'
- t = self.text(x, y, t, **kwargs)
- return t
+ if self._suptitle is not None:
+ self._suptitle.set_text('')
@pelson

pelson Jan 17, 2013

Member

I think this should call the .remove() method, rather than just making it a null Text object.

@dmcdougall

dmcdougall Jan 17, 2013

Member

Or perhaps .update, and put the line below inside an else:?

@pelson

pelson Jan 17, 2013

Member

Either way works. 😉

Member

dmcdougall commented Jan 17, 2013

@pelson Better?

Member

pelson commented Jan 18, 2013

Yep. 👍 from me. @NelleV - are you happy with it?

Contributor

NelleV commented Jan 18, 2013

LGTM: 👍 for merging

Member

dmcdougall commented Jan 18, 2013

Ok. I'll clean up the commit history and merge this (py31 failure is a dud). Thanks.

@dmcdougall dmcdougall added a commit that referenced this pull request Jan 18, 2013

@dmcdougall dmcdougall Merge pull request #1663 from dmcdougall/fix_suptitle
Fix suptitle
527fd07

@dmcdougall dmcdougall merged commit 527fd07 into matplotlib:v1.2.x Jan 18, 2013

@tacaswell tacaswell added a commit to tacaswell/matplotlib that referenced this pull request Jan 23, 2013

@tacaswell tacaswell Fixed code added in 0c20b5c
(PR #1505).

Tests added is #1663 pass with this patch.
17fa943
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment