-
PHP-Proxy PHP-Proxy
Error accessing resource: 429 - Too Many Requests
Powered by PHP-Proxy 5.2.0 -
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add minor ticks on and off in Axis #22761
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
PHP-Proxy
Error accessing resource: 429 - Too Many Requests
Conversation
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.
Thank you for opening your first PR into Matplotlib!
If you have not heard from us in a while, please feel free to ping @matplotlib/developers
or anyone who has commented on the PR. Most of our reviewers are volunteers and sometimes things fall through the cracks.
You can also join us on gitter for real-time discussion.
For details on testing, writing docs, and our review process, please see the developer guide
We strive to be a welcoming and open project. Please follow our Code of Conduct.
Sorry, something went wrong.
All reactions
------------------------------ | ||
|
||
Similar to Axes, minor ticks on Axis can be displayed or removed | ||
using ``minorticks_on()`` and ``minor_ticks_off()``. |
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.
using ``minorticks_on()`` and ``minor_ticks_off()``. | |
using ``minorticks_on()`` and ``minorticks_off()``. |
Sorry, something went wrong.
All reactions
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.
Fixed.
Sorry, something went wrong.
All reactions
lib/matplotlib/scale.py
Outdated
@@ -193,9 +192,9 @@ def set_default_locators_and_formatters(self, axis): | |||
# update the minor locator for x and y axis based on rcParams | |||
if (axis.axis_name == 'x' and mpl.rcParams['xtick.minor.visible'] or | |||
axis.axis_name == 'y' and mpl.rcParams['ytick.minor.visible']): | |||
axis.set_minor_locator(AutoMinorLocator()) | |||
axis.minorticks_off() |
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 should be "on"? Maybe add a test for this ;-). OTOH This is a change of behaviour, in that it only turns the ticks on, doesn't change then to AutoMinorLocator. I'm not sure this new behaviour is bad, but it might have ramifications for folks.
Sorry, something went wrong.
All reactions
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.
Yep, my mistake; fixed it.
The definition of minorticks_off()
uses AutoMinorLocator
unless the scale is log
or symlog
. Looking at the if
condition, wouldn't the logic be better located inside minorticks_on()
and minorticks_off()
?
Sorry, something went wrong.
All reactions
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 think the (existing) test below covers minorticks_on()
, but there are no tests for minorticks_off()
. The code passes pytest
on test_ticker.py
with minorticks_on()
.
matplotlib/lib/matplotlib/tests/test_ticker.py
Lines 1427 to 1442 in 6c3412b
def test_minorticks_rc(): | |
fig = plt.figure() | |
def minorticksubplot(xminor, yminor, i): | |
rc = {'xtick.minor.visible': xminor, | |
'ytick.minor.visible': yminor} | |
with plt.rc_context(rc=rc): | |
ax = fig.add_subplot(2, 2, i) | |
assert (len(ax.xaxis.get_minor_ticks()) > 0) == xminor | |
assert (len(ax.yaxis.get_minor_ticks()) > 0) == yminor | |
minorticksubplot(False, False, 1) | |
minorticksubplot(True, False, 2) | |
minorticksubplot(False, True, 3) | |
minorticksubplot(True, True, 4) |
Sorry, something went wrong.
All reactions
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.
Don't we need to change ~.Axes.minortick_on
as well?
I think overall this is a welcome addition. Lets try and leave as many breadcrumbs in the docs as possible because folks often get frustrated that the defaults interact difficultly with the more custom locators and tickers.
Sorry, something went wrong.
All reactions
lib/matplotlib/scale.py
Outdated
@@ -193,9 +192,9 @@ def set_default_locators_and_formatters(self, axis): | |||
# update the minor locator for x and y axis based on rcParams | |||
if (axis.axis_name == 'x' and mpl.rcParams['xtick.minor.visible'] or | |||
axis.axis_name == 'y' and mpl.rcParams['ytick.minor.visible']): | |||
axis.set_minor_locator(AutoMinorLocator()) | |||
axis.minorticks_on() |
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 line still isn't being hit by the tests? Can we add a test here?
Sorry, something went wrong.
All reactions
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 think the test_minorticks_rc
in test_ticker.py
only covers linear
scale. I can add a test.
Sorry, something went wrong.
All reactions
Trying to implement a test which hits all scales; it seems like there are problems. If I understand correctly:
Solution 1: Add every scale name as a condition to Solution 2: (better?) Add class variables in the scale = self._scale
# on
minor_locator = scale.get_minor_locator()
self.set_minor_locator(minor_locator)
# off
self.set_minor_locator(mticker.NullLocator()) This should work for scales added in future as long as they have the variables defined. Documentation for Custom Scale can be updated to set the variables. In both cases, tests for minor ticks can be looped through I am new to this codebase; let me know if I missed anything. |
All reactions
Sorry, something went wrong.
Thanks, the issues syncing up scales and default locators etc have been a pretty large pain as more scales have been added. I don't know that this PR needs to fix all the woes - if the testing you have in here is as good as the testing you had before, I think its fair enough to get this change in as an improvement, and save sorting out default scale locators and formaters for future work. Thanks a lot for looking into it! |
All reactions
Sorry, something went wrong.
In that case, I can:
This way, toggling minor ticks would work for built-in scales with minimum modifications to |
All reactions
Sorry, something went wrong.
Power cycling to restart the tests. |
All reactions
Sorry, something went wrong.
66124fc
to
3358507
Compare
I have amended the commit seeing that the tests were failing for many scales. Were the rcParams |
All reactions
Sorry, something went wrong.
b6283c1
to
20402e8
Compare
this needs the docs fixed:
|
All reactions
Sorry, something went wrong.
Removed the ambiguity in |
All reactions
Sorry, something went wrong.
Hi @n-aswin - this needs a rebase and then I am assuming it is ready for another round of reviews? If you need help rebasing, here's a nice guide. If you have questions, let us know! |
All reactions
Sorry, something went wrong.
9724a0c
to
5c0afab
Compare
@n-aswin is this ready for review? |
All reactions
Sorry, something went wrong.
Sorry, forgot to comment after the update. I have rebased the commits; should be OK now. I had done this quite some time ago. Let me know if this needs changes. |
All reactions
-
👍 1 reaction
Sorry, something went wrong.
If the PR is ready for review, can you please update it by removing the draft status using the GitHub web interface? Otherwise, it will be skipped over by maintainers, as draft PRs are considered not yet ready to review. Thanks! |
All reactions
Sorry, something went wrong.
5c0afab
to
f65b762
Compare
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 looks good to me. Seems a useful addition and maybe we should merge soonish to see what it catches and iterate on fixes
Sorry, something went wrong.
All reactions
-
👍 1 reaction
power cycled to re-run tests against merging to current main |
All reactions
Sorry, something went wrong.
Looks like it just needs an addition to the type stubs to get the tests passing again. |
All reactions
Sorry, something went wrong.
f65b762
to
c6dc3a1
Compare
I rebased this, and added the missing type hints. |
All reactions
Sorry, something went wrong.
Thank you for your work @n-aswin and congratulations on your first merged Matplotlib PR 🎉 I hope we hear from you again. |
All reactions
-
😄 1 reaction
Sorry, something went wrong.
Thanks! |
All reactions
Sorry, something went wrong.
oscargus
github-actions[bot]
jklymak
Successfully merging this pull request may close these issues.
PHP-Proxy
Error accessing resource: 429 - Too Many Requests
PR Summary
Simialar to
Axes
, minor ticks can be turned on or off inAxis
usingaxis.minorticks_on()
oraxis.minorticks_off()
.PR Checklist
Tests and Styling
pytest
passes).flake8-docstrings
and runflake8 --docstring-convention=all
).Documentation
doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).