Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.1k
Allow Artists to show pixel data in cursor display#3989
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
lib/matplotlib/backend_bases.py Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Should also look atax.collections (that is where things like scatter live) and maybeax.patches
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
and the order should beax.collections + ax.patches + ax.lines + ax.artists + ax.images to match the order used for sorting out the rendering order inAxes.draw (aroundhttps://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/axes/_base.py#L1993 images are special cased around line 2030).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
They then get ordered by zorder anyway:https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/axes/_base.py#L2036
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Ok then. So how to handle composite images? It does not seem feasible to recreate the composite every time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
TheAxesImage could composite the specific pixel on demand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I think to first order, just ignore the compositing and use the top image.
The in-place compositing is only for some of the vector backends which can't do it them selves (ex pdf) to try and save space (so you don't have multiple overlapping images) but it leads to other bugs as all images get smashed to the same zorder relative to the other lines etc. In Agg (which backs all but 3 (gtkcairo, macsox and windows) of the interactive backends) the wholeif _do_composite block is skipped and the compsiting is taken care of at the c++ layer.
blink1073 commentedJan 19, 2015
How's that? I noticed |
blink1073 commentedJan 19, 2015
However, it looks like |
tacaswell commentedJan 19, 2015
Probably worth having a top-level module for useful event handlers, which I think we greatly reduce the threshold to get people using the event system.@WeatherGod@joferkington thoughts? Yes to separate PR for re-ordering |
blink1073 commentedJan 19, 2015
I think we do need to handle compositing. For instance, if I run thisexample, I get the Zdata for the overlay layer. How about just checking for |
blink1073 commentedJan 19, 2015
Well, the more I think about it the more I agree that the top image should get priority. The canny value really is the point of the example. |
blink1073 commentedJan 19, 2015
Added |
blink1073 commentedJan 20, 2015
Do I still "need revision"? |
tacaswell commentedJan 20, 2015
Looks good to me. I am a tad wary of the I would like@WeatherGod to weigh in. |
blink1073 commentedJan 20, 2015
What do you mean "does not use |
blink1073 commentedJan 20, 2015
Meaning it should be a static method? |
blink1073 commentedJan 20, 2015
Either way I think it belongs in the class so it can be overridden. |
tacaswell commentedJan 20, 2015
Yes, it is an instance method which does not refer to it's instance and I can't think of a use case where you would want to (but I may just have poor imagination). I thought about suggesting to move it to |
blink1073 commentedJan 20, 2015
I'd worry that adding a |
tacaswell commentedJan 20, 2015
This also needs an entry inhttps://github.com/matplotlib/matplotlib/tree/master/doc/users/whats_new |
blink1073 commentedJan 20, 2015
Done. |
tacaswell commentedFeb 17, 2015
@matplotlib/developers Can this get eyes from someone else but me? This addresses a long standing and frequent feature request in a pleasingly general way. |
lib/matplotlib/artist.py Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Why do you want to use a string for this? Shouldn't "data" always be numeric?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This allows theArtist to control the display of numbers, similar to the existingax.format_coord.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I agree with@efiring on this one. I can think of a lot of use cases (e.g. interactive sampling) where it would be very convenient to access a "raw" value. Returning a numerical value would make this method useful for a lot more than just display.
You already have a separate method for the formatting, so it's only slightly more verbose to flip the function calls on their head and make the displayed string usingartist.format_zdata(artist.get_zdata()). In my opinion, this would be a better approach overall.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Ha! I originally meant to do that...
tacaswell commentedFeb 20, 2015
@joferkington again. Sorry to pester, but I see you are doing OSS stuff today and would like your feed back on this 😄 |
joferkington commentedFeb 20, 2015
@tacaswell - Absolutely! Sorry I've been so out-of-touch with things lately, as well. |
ENH: Allow Artists to show pixel data in cursor display
Also adds implementation for
AxesImage.Closes#3984.Inspired bympldatacursor.