Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

API: make MaxNLocator trim out-of-view ticks before returning#12105

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

Closed

Conversation

jklymak
Copy link
Member

@jklymakjklymak commentedSep 12, 2018
edited
Loading

PR Summary

Re#11004 This is what I'd do toMaxNLocator to make it return just ticks inside the vlim. I'venot gone through and changed code where we do this post facto, but its a todo for this PR.

Note that I've kept an option when making the locator to continue returning the "extra" locations if desired.

ping@anntzer@efiring for discussion.

Todo

  • make just inaxis.py and change the Locator later...

PR Checklist

  • Has Pytest style unit tests
  • Code isFlake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@anntzer
Copy link
Contributor

The image diffs look worse? (a tick that I think we want went away)

@jklymak
Copy link
MemberAuthor

Specgram doesn’t include 0 in its extents (its 0.2 or something). Should we include ticks that are out of range? If so how far out of range? I’d really argue this is specgrams decision not the decision of the tick locator, but maybe we had the idea that a tick should be made available slightly outside the actual data range? If so how far outside the data range do we want to allow? Is that where all this distance-along-pixel stuff came from?

@anntzer
Copy link
Contributor

Oh sorry, I didn't realize that. In which case I definitely agree with not to put the tick (I think the distance-along-pixel was there for this reason, but only correcting floating point errors).
In fact running the specgram example as of master showcased another funny issue: the tick at 0.0 is present when my window is at its default (rcparam default) size, but disappears if I maximize the window...

@ImportanceOfBeingErnest
Copy link
Member

ImportanceOfBeingErnest commentedSep 13, 2018
edited
Loading

It sounds quite natural to only return those tick locations that are within the (closed) interval of [vmin,vmax]. However for some reason there are currently more tick locations returned. I reckon there must be a reason for this; possibly this is a workaround for some rendering problem? In any case I guess it makes sense to find out the reason and then make sure the trunkated version proposed here would not produce the original problem again.

tacaswell reacted with thumbs up emoji

@jklymak
Copy link
MemberAuthor

The use case I know of where you want more ticks is automatic levels forcontour where you want the levels to bracketvmin andvmax. So I kept a kwarg for this casetrim_outside=False

@efiring
Copy link
Member

Classic-mode autoscalingrequires having the ticks outside the range. The autoscaling determines the range such that lower limit is the largest tick location less than or equal to the data vmin, and similarly for the upper an vmax. The original floating-point slop fiddling, later expanded to work in pixel space, was mainly related to this. For example, when the range is large enough that the ticks fall on integers, one doesn't want tiny and accidental floating point deviations from integers to affect the view limits and ticks.

@efiring
Copy link
Member

This looks like the origin of the half-pixel adjustment:255f213

@jklymak
Copy link
MemberAuthor

Classic-mode autoscaling requires having the ticks outside the range. The autoscaling determines the range such that lower limit is the largest tick location less than or equal to the data vmin, and similarly for the upper an vmax. The original floating-point slop fiddling, later expanded to work in pixel space, was mainly related to this. For example, when the range is large enough that the ticks fall on integers, one doesn't want tiny and accidental floating point deviations from integers to affect the view limits and ticks.

OK, for classic auto scaling we can easily just use the "trim_outside" flag

This PR includes a tolerance based on a fraction of vmax-vmin to account for floating point slop. I set it unscientifically at 1e-10, but we could do something larger to let it have more slop.

@jklymak
Copy link
MemberAuthor

jklymak commentedSep 13, 2018
edited
Loading

The original issue in#1310 was a floating point mismatch with >. While I admit making the tolerance one pixel fixed the floating point error a) it means we have to do some transforms to figure out that size in data space and b) it means the chosen ticks depend on the pixel size. That probably is not practically a problem, but is not very good theoretically.

The approach here still scales by the data range but just chooses a small tolerance that is very unlikely to be visible, but is well within floating point tolerance

@jklymak
Copy link
MemberAuthor

Looking at the code inaxis it seems to me the proper thing to do is to maketransforms.interval_contains actually be floating-point robust....

I took out theinterval_expanded stuffon master out ofaxis.py (i/e/ w/o this PR), and it all passedtest_axes except for the specgram examples. So, I kind of think its obviated (maybe a 64-bit thing?) I think

  1. that code should go (a bunch fewer transforms!)
  2. interval_contains should be made floating point robust.
  3. MaxNLocator should only return ticks between vmin and vmax according to the robustinterval_contains

@@ -1052,50 +1052,8 @@ def _update_ticks(self, renderer):
ihigh = locs[-1]
tick_tups = [ti for ti in tick_tups if ilow <= ti[1] <= ihigh]

# so that we don't lose ticks on the end, expand out the interval ever
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

interval_contains below is modified to accept floating point slop, so this doesn't need to be here any more.

@jklymakjklymakforce-pushed theapi-change-MaxNLocator-trim branch 2 times, most recently from9ca82e1 to3aee68dCompareSeptember 14, 2018 21:01
@tacaswelltacaswell added this to thev3.1 milestoneSep 15, 2018
@jklymakjklymakforce-pushed theapi-change-MaxNLocator-trim branch from550a981 to73adcacCompareSeptember 17, 2018 16:39
@jklymak
Copy link
MemberAuthor

I think this PR is obsolete now...

@jklymakjklymak deleted the api-change-MaxNLocator-trim branchJanuary 30, 2019 23:03
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
v3.1.0
Development

Successfully merging this pull request may close these issues.

5 participants
@jklymak@anntzer@ImportanceOfBeingErnest@efiring@tacaswell

[8]ページ先頭

©2009-2025 Movatter.jp