Skip to content

Apply colorbar formatter to cursor Z data #5425

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

Closed
wants to merge 1 commit into from
Closed

Apply colorbar formatter to cursor Z data #5425

wants to merge 1 commit into from

Conversation

JGoutin
Copy link
Contributor

@JGoutin JGoutin commented Nov 6, 2015

See Issue #5409.

@tacaswell
Copy link
Member

This logic should be in the artist, not in backbend bases.

@WeatherGod
Copy link
Member

Just had a realization as I am heading out the door... we are going to have
to double-check exactly how this interacts with scalar-mappables in
mplot3d. z-coordinate display has been implemented in a manner similar to
the x and y displays, but we probably don't want to override that --
rather, we want to complement it.

On Fri, Nov 6, 2015 at 5:04 PM, Thomas A Caswell notifications@github.com
wrote:

This logic should be in the artist, not in backbend bases.


Reply to this email directly or view it on GitHub
#5425 (comment)
.

@efiring
Copy link
Member

efiring commented Nov 6, 2015

On 2015/11/06 12:04 PM, Thomas A Caswell wrote:

This logic should be in the artist, not in backbend bases.

It looks like the override of Artist.format_cursor_data() should go in
cm.ScalarMappable.

@tacaswell tacaswell added this to the proposed next point release (2.1) milestone Nov 7, 2015
@tacaswell
Copy link
Member

@efiring Then we get into MI territory as cm.ScalarMappable inherits from object and then is used as a mix-in with Artist in the child-classes.

@efiring
Copy link
Member

efiring commented Nov 7, 2015

Yes, I know, I'm concerned about that also. An alternative would be to duplicate the format_cursor_data override in each individual mappable class, and I don't see that as an acceptable option. Another alternative is to put the full logic into Artist.format_cursor_data, but I doubt you like that idea any more than I do. ScalarMappable is the logical place for it; I presume there is a way to do it, but I haven't looked to see whether any special tricks or larger changes would be required.

@tacaswell
Copy link
Member

Maybe

class Artist:
    def get_cursor_data(self, event):
        """
        Get the cursor data for a given event.
        """
        try:
            return self._get_cursor_data(event)
        except AttributeError:
            return None

and then have sub-classes provide _get_cursor_data. We can safely provide that from the ScalarMappable side of the inheritance.

Another option is to not provide a default get_cursor_data method. It is currently opt-in to get in the list of things that are hit anyway, filtering on hasattr(art, 'get_cursor_data') might not be a bad idea?

@efiring
Copy link
Member

efiring commented Nov 7, 2015

@tacaswell, good idea, but we are mixing up two attributes here because of my error in an earlier comment. The present issue is entirely about format_cursor_data. Your suggestion will work nicely with it. A modification would be to use an optional public attribute, fmt_cursor_data in the subclass, analogous to Axes.fmt_xdata, to allow the user to specify a formatter directly. Only if it is not supplied would the colorbar.formatter be used.

@tacaswell tacaswell modified the milestone: 2.1 (next point release) Aug 29, 2017
@timhoffm
Copy link
Member

Superseeded by #12459, I think.

@timhoffm timhoffm closed this Oct 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants