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

Skip to content

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

Closed
wants to merge 8 commits into from

Conversation

KhadraMa
Copy link

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:

  • None: use rcParams
  • int: use explicitly that many ticks
  • 'auto': automatically choose a good number of ticks (the current 4/5 mechanism)

(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

  • Has Pytest style unit tests
  • Code is Flake 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

@QuLogic
Copy link
Member

QuLogic commented Apr 13, 2020

Something went wrong with your rebase; I don't think you wrote 634 commits.

@KhadraMa
Copy link
Author

Yeah, I'm not sure what. I thought I followed the instructions exactly but I must have missed a step.

@KhadraMa
Copy link
Author

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?

@timhoffm
Copy link
Member

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.

@jklymak
Copy link
Member

jklymak commented Jul 29, 2020

@KhadraMa are you going to have time to come back to this or should we close?

@dopplershift
Copy link
Contributor

@jklymak Seeing as this solves an open issue I'm not sure why we'd close?

@jklymak
Copy link
Member

jklymak commented Jul 30, 2020

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.

@KhadraMa
Copy link
Author

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

@dopplershift
Copy link
Contributor

@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:

  • Replaced
  • Rejected ideas
  • No longer applicable
  • So woefully out of date that it's better to start from scratch

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.

@jklymak
Copy link
Member

jklymak commented Jul 31, 2020

@dopplershift perhaps there are better forums for this discussion?

@dopplershift
Copy link
Contributor

@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):
Copy link
Member

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}')
Copy link
Member

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],
Copy link
Member

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?

Comment on lines +197 to +198
mpl.rc_context(rc={'xtick.minor.ndivs': 'auto'})
mpl.rc_context(rc={'ytick.minor.ndivs': 'auto'})
Copy link
Member

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.

Comment on lines +214 to +215
mpl.rc_context(rc={'xtick.minor.ndivs': 2})
mpl.rc_context(rc={'ytick.minor.ndivs': 2})
Copy link
Member

Choose a reason for hiding this comment

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

Ditto.

Comment on lines +2937 to +2940
if self.axis.__name__ == 'xaxis':
self.ndivs = mpl.rcParams['xtick.minor.ndivs']
else:
self.ndivs = mpl.rcParams['ytick.minor.ndivs']
Copy link
Member

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.

@IlievskiV
Copy link
Contributor

@KhadraMa is this PR still relevant and opened to work on? If yes, may I take it over and try to complete it?

@KhadraMa
Copy link
Author

@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

@jklymak
Copy link
Member

jklymak commented Oct 13, 2020

Thanks @KhadraMa I'll close this version....

@jklymak jklymak closed this Oct 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Allow setting default AutoMinorLocator
6 participants