-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Issue #14233 - allow users to set a defualt value for ndivs for minor ticks on x and y axes #16762
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
Conversation
… a corresponding validate function
…ment new functionality
Something went wrong with your rebase; I don't think you wrote 634 commits. |
Yeah, I'm not sure what. I thought I followed the instructions exactly but I must have missed a step. |
I'll be honest, I don't know why the tests are failing. Is there any guidance or advice on how to improve the pull request so that the tests will pass? |
Investigate the reasons for the failed test runs by checking the Details links below . This might help: https://matplotlib.org/devdocs/devel/coding_guide.html#automated-tests You might also want to try running the tests locally https://matplotlib.org/devdocs/devel/testing.html. |
@KhadraMa are you going to have time to come back to this or should we close? |
@jklymak Seeing as this solves an open issue I'm not sure why we'd close? |
Because if no one is working on it, it doesn't make sense to leave open? The original issue is still open, and this work is linked to it. This was a student project, and after the semester they often do not come back to their PRs. |
Hi @jklymak, sorry for the late reply. I understand your concern - especially since I haven't been actively working on this for a few weeks now. The summer's been more hectic (and honestly more exhausting) than I expected. I still have every intention of finishing this though, so if it isn't too much trouble to keep it open I'd appreciate it. Thanks |
@jklymak I don't know what philosophy for closing PRs has been discussed on the dev calls, so maybe my ideas are in opposition to the project writ large. IMO you only close PRs for being:
Yes it's linked from the issue, but that means people only stumble upon it if they're trying to fix that issue. I'd prefer leaving it open because, even if abandoned, it represents work that could go into matplotlib with a little more effort. My $0.02. |
@dopplershift perhaps there are better forums for this discussion? |
@jklymak Probably. I've added the topic to the agenda for Monday's dev call. |
@@ -775,6 +775,21 @@ def validate_hatch(s): | |||
validate_dashlist = _listify_validator(validate_floatlist) | |||
|
|||
|
|||
def validate_minor_tick_ndivs(n): |
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 probably defer to validate_int_or_None
and then check that it's non-negative. And also should be private.
if (0 <= n): | ||
return n | ||
else: | ||
raise RuntimeError(f'Value must be >=0; got {n}') |
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.
Should be ValueError
.
@@ -1287,6 +1302,8 @@ def _convert_validator_spec(key, conv): | |||
"xtick.minor.bottom": validate_bool, # draw bottom minor xticks | |||
"xtick.major.top": validate_bool, # draw top major xticks | |||
"xtick.major.bottom": validate_bool, # draw bottom major xticks | |||
"xtick.minor.ndivs": ['auto', validate_minor_tick_ndivs], |
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 don't think this actually works the way you want, does it?
mpl.rc_context(rc={'xtick.minor.ndivs': 'auto'}) | ||
mpl.rc_context(rc={'ytick.minor.ndivs': 'auto'}) |
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 needs to be used as a context manager, or it has no effect. Or you can set rcParams
directly; they'll be reset at the end of the test.
mpl.rc_context(rc={'xtick.minor.ndivs': 2}) | ||
mpl.rc_context(rc={'ytick.minor.ndivs': 2}) |
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.
Ditto.
if self.axis.__name__ == 'xaxis': | ||
self.ndivs = mpl.rcParams['xtick.minor.ndivs'] | ||
else: | ||
self.ndivs = mpl.rcParams['ytick.minor.ndivs'] |
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 won't work for 3D; it normally uses the x setting for z.
Also, better to use self.axis.axis_name
instead.
@KhadraMa is this PR still relevant and opened to work on? If yes, may I take it over and try to complete it? |
@IlievskiV go for it. With the way things are going it would be a while before I have time to work on this again - but it's open and should be finished so yeah, have at it |
Thanks @KhadraMa I'll close this version.... |
PR Summary
Pull request to resolve #14233 - Allow setting default AutoMinorLocator
I've added two new parameters to rcParams (rcsetup.py) and added a new case statement in the call method of the AutoMinorLocator class (ticker.py). The functionality is as follows:
Allowed value of rcParams: {'auto', int}
Allowed value of Autominorticker(n): {'auto', int, None}
with:
(functionality description pulled from timhoffm's comment from May 30, 2019)
Hi, this is my first pull request, so I'm sure there need to be some changes/updates before it's ready to be merged and I'm happy to make them. I'm a student at UTSC and while this is technically part of a course assignment I want to make clear that I'm personally interested in making a contribution and won't ghost you guys when the course ends (I know there's been some controversy about students contributing lately, but no need to worry).
PR Checklist