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

Axes3d error on set_title #1759

Closed
janrito opened this issue Feb 18, 2013 · 5 comments
Closed

Axes3d error on set_title #1759

janrito opened this issue Feb 18, 2013 · 5 comments
Milestone

Comments

@janrito
Copy link

janrito commented Feb 18, 2013

The Axes3D calls set_title with an empty loc parameter, which throws an error.

/usr/local/lib/python2.7/dist-packages/mpl_toolkits/mplot3d/axes3d.pyc in set_title(self, label, fontdict, **kwargs)
   2362 
   2363     def set_title(self, label, fontdict=None, **kwargs):
-> 2364         Axes.set_title(self, label, fontdict, **kwargs)
   2365         (x, y) = self.title.get_position()
   2366         self.title.set_y(0.92 * y)

/usr/local/lib/python2.7/dist-packages/matplotlib/axes.pyc in set_title(self, label, loc, fontdict, **kwargs)
   3216             title = {'left': self._left_title,
   3217                      'center': self.title,
-> 3218                      'right': self._right_title}[loc.lower()]
   3219         except KeyError:
   3220             raise ValueError("'%s' is not a valid location" % loc)

AttributeError: 'NoneType' object has no attribute 'lower'

If the loc parameter is passed explicitly to set_title:

p, ax = plt.subplots(subplot_kw={'projection': '3d'})
ax.set_title('Title', loc='center')

the loc parameter is passed twice, and the following error occurs:

/usr/local/lib/python2.7/dist-packages/mpl_toolkits/mplot3d/axes3d.pyc in set_title(self, label, fontdict, **kwargs)
   2362 
   2363     def set_title(self, label, fontdict=None, **kwargs):
-> 2364         Axes.set_title(self, label, fontdict, **kwargs)
   2365         (x, y) = self.title.get_position()
   2366         self.title.set_y(0.92 * y)

TypeError: set_title() got multiple values for keyword argument 'loc'
@WeatherGod
Copy link
Member

Looks like this is a regression in master only. Possibly caused by the recent changes to set_title()? I am not exactly sure what is happening here, but it isn't caused by Axes3D, so this is a release-blocker.

@efiring
Copy link
Member

efiring commented Feb 19, 2013

The problem is that Axes3D is calling Axes.set_title with fontdict as a positional argument, not a kwarg, so it is being mis-interpreted as loc, because that is now the third argument in Axes.set_title. I think that if you change line 2364 to use "fontdict=fontdict", everything will work.

@WeatherGod
Copy link
Member

Wouldn't the real bug be that we needlessly changed the call signature for
set_title()? If this broke for mplot3d, imagine how easily it would break
for our users? Now, I will certainly change the mplot3d code to pass a
kwarg, but I think it is entirely reasonable to put "loc" after "fontdict".

@efiring
Copy link
Member

efiring commented Feb 19, 2013

Changing the relative positions of the named kwargs in set_title is a reasonable thing to do, given the history of it. You could make that change in the same PR; now is the time to change it, since there has been no release with the loc kwarg in set_title.

I think the rationale for having loc come before fontdict is that it is a more natural to be able to write "ax.set_title('some title', 'left')', leaving out the loc keyword, than to do that with the fontdict, which is a complex beast. That has to be weighed against the possibility of breakage, given the long history of set_title with the fontdict kwarg following the string argument.

@WeatherGod
Copy link
Member

Submited PR #1764

dmcdougall added a commit that referenced this issue Mar 23, 2013
Make loc come after fontdict in set_title. Closes #1759
HubertHolin pushed a commit to HubertHolin/matplotlib that referenced this issue Apr 7, 2013
HubertHolin pushed a commit to HubertHolin/matplotlib that referenced this issue Apr 8, 2013
HubertHolin pushed a commit to HubertHolin/matplotlib that referenced this issue Apr 8, 2013
HubertHolin pushed a commit to HubertHolin/matplotlib that referenced this issue Apr 11, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants