Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add simple delta cursor to toolbar for zoom mode #12948

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

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

roger-
Copy link

@roger- roger- commented Dec 7, 2018

Adds a small delta x/y cursor to the toolbar when zooming. Sorta related to #7216.

Minor GUI feature so no Pytest required (?). Flake8 looks good.

This will need some changes to work in polar mode but I’m not sure what’s the best way. Also might be useful to add the Euclidean distance (ds=xxx). Will await feedback.

ujvykmu

@jklymak
Copy link
Member

jklymak commented Dec 7, 2018

Can you take a screenshot so we can understand what you are proposing? It’s not immediately obvious from code or description. Thanks!

@roger-
Copy link
Author

roger- commented Dec 7, 2018

Sure: https://imgur.com/UJVyKmu

@anntzer
Copy link
Contributor

anntzer commented Dec 7, 2018

I guess I'm +0 for this (can be useful), but -1 on adding Euclidian distance, as it assumes too much about the axes, namely, that they have the same units. For example, if x is in seconds and y in meters, then the distance is meaningless (whereas delta x and delta y are still meaningful), and Matplotlib should avoid displaying meaningless values by default.

@jklymak
Copy link
Member

jklymak commented Dec 7, 2018

Seems fine if it doesn't slow things down too much...

@roger-
Copy link
Author

roger- commented Dec 7, 2018

PR updated:

  1. remove non-ASCII characters
  2. changed format from (Δx=123.45 Δy=234.56) to (Δ: x=123.45 y=234.56) so it works with polar plots etc.

@tacaswell
Copy link
Member

What does this do with units on the axes (for example datetimes?)

@tacaswell tacaswell added this to the v3.1 milestone Dec 7, 2018
@roger-
Copy link
Author

roger- commented Dec 7, 2018

Doesn’t work because of format_coord(). One option is to test for datetimes and treat them specially. Is there a cleaner approach?

@timhoffm
Copy link
Member

timhoffm commented Dec 8, 2018

  1. changed format from (Δx=123.45 Δy=234.56) to (Δ: x=123.45 y=234.56) so it works with polar plots etc.

I find this a bit confusing. The delta should be next to the coordinate names as in the first version. One way would be to to extend the format functions and to implement the delta-rendering there:
def format_coord(self, x, y, is_delta=False).

This is just a quick idea, not really thought through. Maybe alternatively/additionally one would need complete handling of delta formatting all across the formatter mechanism.

@tacaswell
Copy link
Member

One option is to test for datetimes and treat them specially

There should be a story on how to handle unit-full axis in general rather than special casing datetime.

As cool and useful looking as this is, I am wary of merging it without at least a clear path to dealing with units. Maybe just turn this functionality off if either axis has units attached?

@roger-
Copy link
Author

roger- commented Dec 8, 2018

@timhoffm

Maybe alternatively/additionally one would need complete handling of delta formatting all across the formatter mechanism.

I could also parse the string from format_coord() and add in the deltas. A bit hacky though.

@tacaswell

Maybe just turn this functionality off if either axis has units attached

Is there a simple way to detect this?

@timhoffm
Copy link
Member

timhoffm commented Dec 8, 2018

I could also parse the string from format_coord() and add in the deltas. A bit hacky though.

No. That's too hacky and could easily get broken in the future.

@tacaswell
Copy link
Member

ax.have_units() ( see https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.have_units.html?highlight=have_units#matplotlib.axes.Axes.have_units )

I would not trust parsing the format string as that is something users can set at run time.

@roger-
Copy link
Author

roger- commented Dec 10, 2018

PR updated:

  1. reverted display format
  2. only enable when there are no axis units

I think this is the best approach as the zoom rectangle is in Cartesian and knowing its dimensions won't be useful in other units (e.g. polar, lat/lon, etc.) Might be nice to handle dates, but I don't think there's currently a clean way.

@tacaswell tacaswell modified the milestones: v3.1.0, v3.2.0 Feb 23, 2019
@tacaswell
Copy link
Member

@roger- Sorry we have gone quite on this.

I am pushing it to the 3.2 tag as I not sure what the current state of the discussion is.

@timhoffm
Copy link
Member

I think this is good as a minimal improvent for a defined and limited case.

Just needs fixing the line length to placate flake8.

@QuLogic
Copy link
Member

QuLogic commented Sep 10, 2020

This needs a rebase to fix conflicts, but it doesn't seem like there were any outstanding issues before that.

@timhoffm
Copy link
Member

timhoffm commented Nov 2, 2020

This needs a revision: The message generating code has moved and in that function, we don't have access to the start click location _xypress.

Marking as medium-difficult because one has to dig though the design to find a reasonable approach for storing and accessing the click state.

@timhoffm timhoffm added the Difficulty: Medium https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues label Nov 2, 2020
@roger-
Copy link
Author

roger- commented Nov 2, 2020

@timhoffm
I could use some help with this if anyone is willing to volunteer.

@timhoffm
Copy link
Member

timhoffm commented Nov 4, 2020

@roger- You need the click position later when processing drag events. The problem is that we don't have a good concept for storing that position. Coming up with a solution for that is the prerequisite for moving forward. It requires digging into the code and ideally a bit of design experience.

@roger-
Copy link
Author

roger- commented Nov 5, 2020

@timhoffm Not something I can work on right now, so I'll leave this until I have time or someone else picks up the reins.

@QuLogic QuLogic modified the milestones: v3.4.0, unassigned Jan 21, 2021
@story645 story645 modified the milestones: unassigned, needs sorting Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Difficulty: Medium https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues status: needs rebase status: needs revision status: orphaned PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants