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

Skip to content

Need a way to check if an axis minor or major grid is on #19021

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

Open
jklymak opened this issue Nov 26, 2020 · 5 comments
Open

Need a way to check if an axis minor or major grid is on #19021

jklymak opened this issue Nov 26, 2020 · 5 comments

Comments

@jklymak
Copy link
Member

jklymak commented Nov 26, 2020

It appears we have no public interface to check whether the grid is on? Downstream libraries are now replacing the private self.xaxis._gridOnMinor with the private self.xaxis._minor_tick_kw["gridOn"], which seems even worse.

Seems we need self.xaxis.grid_on(which='minor') and self.xaxis.grid_on(which='major')?

Originally posted by @jklymak in #18769 (comment)

@jklymak jklymak added this to the v3.3.4 milestone Nov 26, 2020
@anntzer
Copy link
Contributor

anntzer commented Nov 26, 2020

I'd guess the normal way to access that info would be ax.xaxis.get_gridlines()[0].get_visible()? (loop over the gridlines and decide what you want to do if you want to additionally handle the case of not all gridlines having the same visibility)

I'm not sure I'd want a new method, though (what would we do if the user manually switched the visibility of only a subset of gridlines?).

@jklymak
Copy link
Member Author

jklymak commented Nov 26, 2020

OK, that seems public enough to me. OTOH I don't see a way to get the minor gridlines from this? So maybe add a get_gridlines(which='minor'/'major'/'both')? Or a new get_minorgridlines?

@jklymak
Copy link
Member Author

jklymak commented Nov 26, 2020

I guess just ax.xaxis.get_minor_ticks()[0].gridline.get_visible()...

@mwaskom
Copy link

mwaskom commented Nov 28, 2020

Some downstream packages use that approach: https://github.com/mwaskom/seaborn/blob/2717408b564994002fe08f72ba2dd7e1acf359b6/seaborn/distributions.py#L827...L830

IMO Axis.grid_on is not very obviously a "status checker" method vs a "do an action" method...

@jklymak jklymak modified the milestones: v3.3.4, v3.4.0, v3.4.1 Jan 27, 2021
@QuLogic QuLogic modified the milestones: v3.4.1, v3.5.0 Mar 29, 2021
@QuLogic QuLogic modified the milestones: v3.5.0, v3.6.0 Aug 17, 2021
@QuLogic QuLogic modified the milestones: v3.6.0, v3.7.0 Aug 24, 2022
@QuLogic QuLogic modified the milestones: v3.7.0, future releases Jan 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants