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

getter for ticks for colorbar #6170

Merged
merged 1 commit into from Mar 31, 2016
Merged

Conversation

yongzhez
Copy link
Contributor

This is my proposed inclusion for #5792. I do note that it hands backs the ticks in a list instead of an array, is that a problem by any chance?

@tacaswell
Copy link
Member

Can you add a simple test for this?

Is this consistent with similar method on the x and y axis?

Does this do the mapping to data space?

@tacaswell tacaswell added this to the 2.1 (next point release) milestone Mar 17, 2016
@yongzhez
Copy link
Contributor Author

I've checked and it does work properly with both a horizontal and vertical axis for a colorbar. In relation to testing, what would be consider a good test? is simply comparing the ticks that are set and the ticks that are return by the method enough? Also, still wondering if having ticks returned in a list is acceptable.

:return: an array of all ticks in the locator
"""

return self.locator.tick_values(0, 0)
Copy link
Member

Choose a reason for hiding this comment

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

self.locator can be None

@tacaswell
Copy link
Member

By consistent, I mean what would you use to get the ticks are for the x or y axis.

A good test would be to construct an example where you know what the tick should be and then check that they are in fact what you expect.

I think this is going to have to be a bit more involved and possible involve a refactor of _ticker

@yongzhez
Copy link
Contributor Author

I've created the necessary implementation of xticks and yticks in correlation to the behaviour that axis class does. I'm creating the tests right now for my implementation . Also, refactoring _ticker might not be necessary considering that the 2 methods I created are the same as axis's ticker getters behaviour.

@efiring
Copy link
Member

efiring commented Mar 24, 2016

@yongzhez I don't think those two methods are useful for Colorbar. It looks like #6216 is closer to doing the right thing, but still needs work. Notice that a Colorbar has ticks only on one axis; and that the tick locations as returned by your methods are not in data coordinates, so they don't address #5792.

@yongzhez
Copy link
Contributor Author

I see, I used your suggestion to basically add a _tick_data_values field. I also added a test to correspond with this to test for the 2 returned list for a horizontal and vertical colorbar. I chose to go the path of a getter simply for consistency sake, but I can change when required.

@yongzhez
Copy link
Contributor Author

I've added the case that the user does not set their own ticks and updated the tests to correspond.

@efiring
Copy link
Member

efiring commented Mar 25, 2016

I'm sorry, but I think your approach is still not correct. We don't want to recalculate the data tick values, we want to save them at the point where they are already being calculated. And it looks to me like the values you are recalculating or grabbing are not the data values at all.

@yongzhez
Copy link
Contributor Author

I apologize @efiring , I have noted that update_ticks() already calls _ticker() so I can just assign the ticks there. I also now return the data as a list of all the ticks. Is that sufficient?

@efiring
Copy link
Member

efiring commented Mar 25, 2016

@yongzhez I think you missed a critical point: the "ticks" returned by _ticker are not in data space, so they are not the values we want. What is needed is to save the b values that are generated in _ticker and used by it to calculate the "ticks" and "ticklabels".
Since you and a group led by @TheJenniferYu (#6216) are working on solving the same issue, please join forces and consolidate your work in a single PR.

@yongzhez
Copy link
Contributor Author

@efiring it's pretty late where I live so I wasn't able to contact the other team, I think I understand what you want me to do and I pushed a fix.

@@ -592,6 +597,7 @@ def _ticker(self):
formatter.set_data_interval(*intv)

b = np.array(locator())
self._tick_data_values = b
Copy link
Member

Choose a reason for hiding this comment

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

It looks like you are close, but shouldn't you save the b values after all potential modifications? See the following lines.

@yongzhez
Copy link
Contributor Author

@efiring I made the changes.

@efiring efiring merged commit 5d0ca1d into matplotlib:master Mar 31, 2016
@efiring
Copy link
Member

efiring commented Mar 31, 2016

Thank you, @yongzhez!

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

4 participants