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

Fix issue 1172 #2618

Merged
merged 2 commits into from Nov 30, 2013
Merged

Fix issue 1172 #2618

merged 2 commits into from Nov 30, 2013

Conversation

tacaswell
Copy link
Member

when labelsize was passed into tick_param as a string, it is correctly dealt with by the Text object used in the ticklabel, but the Tick saves the string which leads to addition problems later.

# -> points. grab the integer from the `Text` object
# instead of saving the string representation
setattr(self, '_' + k,
getattr(self.label1, 'get_{}'.format(k))())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This empty {} in format doesn't work on Python 2.6, unfortunately.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition, the present version is very hard to read. Breaking it up with one or two temporary variables would help, in addition to going back to the good old percent notation. Actually, it looks like string addition would be enough. Maybe something like this:

text_attr_getter = getattr(self.label1, 'get_' + k)
setattr(self, '_' + k, text_attr_getter())

or

text_attr = getattr(self.label1, 'get_' + k)()
setattr(self, '_' + k, text_attr)
Or, have I misinterpreted what is supposed to happen here?

Also, you are not using v at all now, so the iterations should be over ```keys```.

@mdboom
Copy link
Member

mdboom commented Nov 29, 2013

Looks good, once Travis passes.

@tacaswell
Copy link
Member Author

@efiring This clearer?

# -> points. grab the integer from the `Text` object
# instead of saving the string representation
getter_fun = 'get_' + k
v = getattr(self.label1, getter_fun)()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better, thank you. Actually, at this point, it is simple enough that you could eliminate the "getter_fun" and substitute the string directly into the getattr argument. I think that would be entirely readable, nice and concise.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done and commits squashed.

Do this by getting the size value back from the underlying text
object.
@efiring
Copy link
Member

efiring commented Nov 30, 2013

There is an intermittent Travis failure in test_bbox_inches_tight_suptitle_legend involving a difference of 3 pixels between the size of the plot and the baseline size. It's a nuisance, but not related to this PR.

efiring added a commit that referenced this pull request Nov 30, 2013
@efiring efiring merged commit 5400c1d into matplotlib:v1.3.x Nov 30, 2013
@tacaswell tacaswell deleted the fix_issue_1172 branch November 30, 2013 00:08
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

Successfully merging this pull request may close these issues.

None yet

3 participants