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

Locator interface #1064

Merged
merged 6 commits into from Aug 16, 2012
Merged

Locator interface #1064

merged 6 commits into from Aug 16, 2012

Conversation

pelson
Copy link
Member

@pelson pelson commented Aug 9, 2012

I have a need to get ticks for a given range, and the matplotlib Locator seemed like the perfect fit. Unfortunately, the Locator class needs an Axis to function (even if that Axis is a DummyAxis instance).

This PR makes it easy for some Locators to expose their underlying cleverness without the need for an Axis instance.

@mdboom
Copy link
Member

mdboom commented Aug 9, 2012

Looks good. Maybe add a unit test and example of how to use this in the new way (without an Axes)? Not sure where that example should go -- it's non-visual (well, non-plot-producing) so it might be hard to find.

'Return the locations of the ticks'
return self.tick_values(None, None)

def tick_values(self, vmin, vmax):
Copy link
Member

Choose a reason for hiding this comment

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

vmin -> dmin etc. for consistency

Copy link
Member Author

Choose a reason for hiding this comment

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

For self consistency I would change all signatures in this module from dmin to vmin. Is there a consistency outside of this file which would make dmin preferable?

@efiring
Copy link
Member

efiring commented Aug 9, 2012

I like this idea--I never liked the dummy axis.
Is there any reason not to remove most or all of the separate call definitions? It looks like they could be inherited from the base class.

'Return the locations of the ticks'
"""Return the locations of the ticks"""
# note: some locators return data limits, other return view limits,
# hence there is no *one* interface to call self.tick_values.
Copy link
Member Author

Choose a reason for hiding this comment

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

@efiring said:

Is there any reason not to remove most or all of the separate call definitions? It looks like they could be inherited from the base class.

Unfortunately some __call__ methods use self.axis.get_view_interval others use self.axis.get_data_interval() so I couldn't comfortably make that change.

@pelson
Copy link
Member Author

pelson commented Aug 10, 2012

Looks good. Maybe add a unit test and example of how to use this in the new way (without an Axes)?

Yes, I'd be happy to put in a unit test, but not sure a usage example would be that helpful/interesting.

@pelson
Copy link
Member Author

pelson commented Aug 13, 2012

Ok. I've just added some tests for some of the Locators, but have not updated the "whats new" section as I am not sure such a menial thing is worthy of such exposure. Happy to make any further alterations though if either of you feel it is necessary.

@pelson
Copy link
Member Author

pelson commented Aug 13, 2012

Will just rebase before it gets reviewed.

@mdboom
Copy link
Member

mdboom commented Aug 14, 2012

The example I was thinking of would just be something to show how, given a range, one could get a list of ticks back. You've made it much easier than before, so we should show how easy it is... ;)

@pelson
Copy link
Member Author

pelson commented Aug 15, 2012

Ok. changelog added.

@efiring efiring merged commit 4526865 into matplotlib:master Aug 16, 2012
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