-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
34854db
7e0d1ca
97640da
139d820
17e4211
fcda62b
8ea9504
02456b8
641304c
3f20d3a
5850150
88b56be
aece695
07745c8
7626394
7b0b6b1
f5ff73f
ea565c6
1429206
e62b0e3
34b4df4
8f266a1
70983ff
cd0e52b
8ce3a6f
bac8dff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -903,26 +903,26 @@ def matchfunc(x): | |
artists.append(self) | ||
return artists | ||
|
||
def get_zdata(self, event): | ||
def get_pixel_data(self, event): | ||
""" | ||
Get the zdata for a given event, as a string message | ||
Get the pixel data for a given event. | ||
""" | ||
return '' | ||
|
||
def format_zdata(self, z): | ||
def format_pixel_data(self, data): | ||
""" | ||
Return *z* string formatted. | ||
Return *pixel data* string formatted. | ||
""" | ||
try: | ||
is_int = isinstance(z[0], int) | ||
is_int = isinstance(data[0], int) | ||
except (TypeError, IndexError): | ||
is_int = isinstance(z, int) | ||
z = [z] | ||
is_int = isinstance(data, int) | ||
data = [data] | ||
if is_i 8000 nt: | ||
z = ', '.join(item for item in z) | ||
data = ', '.join(item for item in data) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How is this working? I don't think I suspect what is going on in your example is that a numpy array is being given and There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, simplified. |
||
else: | ||
z = ', '.join('{:0.3g}'.format(item) for item in z) | ||
return z | ||
data = ', '.join('{:0.3g}'.format(item) for item in data) | ||
return data | ||
|
||
|
||
class ArtistInspector(object): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2799,7 +2799,9 @@ def mouse_move(self, event): | |
artists.remove(event.inaxes.patch) | ||
artists.sort(key=lambda x: x.zorder) | ||
if artists: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Something seems odd about checking if Also, +1 for removing ye olden style DSU in favor of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good call, done. |
||
s += artists[-1].get_zdata(event) | ||
a = artists[-1] | ||
data = a.get_cursor_data(event) | ||
s += 'data= %s' % a.format_cursor_data(data) | ||
if len(self.mode): | ||
self.set_message('%s, %s' % (self.mode, s)) | ||
else: | ||
|
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 the
Artist
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 using
artist.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...