| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| Minor Locator no longer try to avoid overstriking major Locators | ||
| ```````````````````````````````````````````````````````````````` | ||
|
|
||
| Previously, certain locator classes (`LogLocator`, `AutoMinorLocator`) | ||
| contained custom logic to avoid emitting tick locations that collided with | ||
| major ticks when they were used as minor locators. | ||
|
|
||
| This logic has now moved to the Axis class; thus, for example, | ||
| ``xaxis.minor.locator()`` now includes positions that collide with | ||
| ``xaxis.major.locator()``, but ``xaxis.get_minorticklocs()`` does not. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -1013,17 +1013,15 @@ def _set_artist_props(self, a): | |
|
|
||
| def iter_ticks(self): | ||
| """ | ||
| Iterate through all of the major and minor ticks. | ||
| Yield ``(Tick, location, label)`` tuples for major and minor ticks. | ||
| """ | ||
| major_locs = self.major.locator() | ||
| major_ticks = self.get_major_ticks(len(major_locs)) | ||
| major_locs = self.get_majorticklocs() | ||
| major_labels = self.major.formatter.format_ticks(major_locs) | ||
|
|
||
| minor_locs = self.minor.locator() | ||
| minor_ticks = self.get_minor_ticks(len(minor_locs)) | ||
| minor_labels = self.minor.formatter.format_ticks(minor_locs) | ||
|
|
||
| major_ticks = self.get_major_ticks(len(major_locs)) | ||
| yield from zip(major_ticks, major_locs, major_labels) | ||
| minor_locs = self.get_minorticklocs() | ||
| minor_labels = self.minor.formatter.format_ticks(minor_locs) | ||
| minor_ticks = self.get_minor_ticks(len(minor_locs)) | ||
| yield from zip(minor_ticks, minor_locs, minor_labels) | ||
|
|
||
| def get_ticklabel_extents(self, renderer): | ||
| Expand Down Expand Up | @@ -1304,18 +1302,29 @@ def get_ticklines(self, minor=False): | |
| return self.get_majorticklines() | ||
|
|
||
| def get_majorticklocs(self): | ||
| "Get the major tick locations in data coordinates as a numpy array" | ||
| """Get the array of major tick locations in data coordinates.""" | ||
| return self.major.locator() | ||
|
|
||
| def get_minorticklocs(self): | ||
| "Get the minor tick locations in data coordinates as a numpy array" | ||
| return self.minor.locator() | ||
| """Get the array of minor tick locations in data coordinates.""" | ||
| # Remove minor ticks duplicating major ticks. | ||
| major_locs = self.major.locator() | ||
|
Comment thread
Copy link
Copy Markdown
Member
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Qualitywhy not pass the major_locs here, if we don't want to do it in the locator? Agree that its an API change, but I suspect a minor one; this method is not used elsewhere, except in the tests...
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Contributor
Author
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityBecause if anything I think the main API change here is that one cannot call axis.minor.locator() to get the minor tick locations. The main API to do that is now axis.get_minorticklocs(); making it axis.get_minorticklocs(major_locs=axis.get_majorticklocs()) seems a bit of a pain (Also, what about axis.get_ticklocs(minor=True)? Would you now have to pass the major_locs kwarg to get_ticklocs() but only if minor=True? Looks a bit awkward.).
Sorry, something went wrong.
All reactions
|
||
| minor_locs = self.minor.locator() | ||
|
Comment thread
Copy link
Copy Markdown
Member
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Qualityaren't we now calling both locators twice? Seems inefficient to me.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Contributor
Author
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityYes (per the above).
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityOK, actually I'm confused - why are we calling the locator at all here? Do we not cache the existing tick locations in some way? Sorry if I'm being dumb.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Contributor
Author
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI... don't think so? Note that the previous implementation also called the locator.
Sorry, something went wrong.
All reactions
|
||
| transform = self._scale.get_transform() | ||
| tr_minor_locs = transform.transform(minor_locs) | ||
| tr_major_locs = transform.transform(major_locs) | ||
| lo, hi = sorted(transform.transform(self.get_view_interval())) | ||
| # Use the transformed view limits as scale. 1e-5 is the default rtol | ||
| # for np.isclose. | ||
| tol = (hi - lo) * 1e-5 | ||
|
Comment thread
Copy link
Copy Markdown
Member
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality"transformed view limits" means this is now in axes coordinates, right? If so, this is the right thing to do.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Contributor
Author
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityIt's some linear transform away from axes coordinates, so the relative check is equivalent to being done in axes coordinates.
Sorry, something went wrong.
timhoffm reacted with thumbs up emoji
All reactions
|
||
| minor_locs = [ | ||
| loc for loc, tr_loc in zip(minor_locs, tr_minor_locs) | ||
| if not np.isclose(tr_loc, tr_major_locs, atol=tol, rtol=0).any()] | ||
| return minor_locs | ||
|
|
||
| def get_ticklocs(self, minor=False): | ||
| "Get the tick locations in data coordinates as a numpy array" | ||
| if minor: | ||
| return self.minor.locator() | ||
| return self.major.locator() | ||
| """Get the array of tick locations in data coordinates.""" | ||
| return self.get_minorticklocs() if minor else self.get_majorticklocs() | ||
|
|
||
| def get_ticks_direction(self, minor=False): | ||
| """ | ||
| Expand Down | ||
| Back | FazBrowse Home | New Git URL |
Uh oh!
There was an error while loading. Please reload this page.