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

Fixes issue #1960. Account for right/top spine data offset on transform ... #1964

Merged
merged 3 commits into from May 11, 2013

Conversation

cimarronm
Copy link
Contributor

...when doing spine.set_position(). Also includes a testcase for the data locations.

…on transform when doing spine.set_position(). Also includes a testcase for the data locations.
@@ -323,6 +323,8 @@ def _calc_offset_transform(self):
self._spine_transform = ('identity',
mtransforms.IdentityTransform())
elif position_type == 'data':
if self.spine_type in ('right', 'top'):
amount -= 1 # translate left by one to account for right/top data offset of one
Copy link
Member

Choose a reason for hiding this comment

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

Sorry, the comment doesn't enlighten me. Do you know the root cause of this workaround? Is this one pixel? Are you certain that this isn't a snapping issue?

Apologies for the (possibly silly) questions - I would like to understand the underlying need for this change.

Copy link
Member

Choose a reason for hiding this comment

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

It's not one pixel -- it's in axes units which are (0, 1) across the entire axis. Maybe a better comment would be:

The right and top spines have a default position of 1 in axes coordinates.  When specifying the position in data coordinates, we need to calculate the position relative to 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is correct. I updated the code with Michael's suggested comment. Thanks @mdboom

# The right and top spines have a default position of 1 in
# axes coordinates. When specifying the position in data
# coordinates, we need to calculate the position relative to 0.
amount -= 1
Copy link
Member

Choose a reason for hiding this comment

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

Thanks @cimarronm - this is much clearer now.

@pelson
Copy link
Member

pelson commented May 1, 2013

Just needs an doc/api/api_changes.rst entry since this will change some functionality (for the better - by fixing a bug) and I think it is good to go.

Nice work @cimarronm.

👍

@cimarronm
Copy link
Contributor Author

How about:

* Fixed a bug in setting the position for the right/top spine with data 
  position type. Previously, it would draw the right or top spine at
  +1 data offset.

Let me know if that is good or want to improve the wording for doc/api/api_changes.rst

@pelson
Copy link
Member

pelson commented May 2, 2013

Let me know if that is good or want to improve the wording for

That sounds good to me. The api_changes.rst document is there for those who are finding problems when upgrading versions, so something short and to the point is exactly what is needed. Thanks @cimarronm

@cimarronm
Copy link
Contributor Author

Is this good to merge?

mdboom added a commit that referenced this pull request May 11, 2013
…_fix

Fixes issue #1960. Account for right/top spine data offset on transform ...
@mdboom mdboom merged commit af07100 into matplotlib:master May 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

Successfully merging this pull request may close these issues.

None yet

3 participants