-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Support removing inner ticks in label_outer() #24376
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
|
||
Parameters | ||
---------- | ||
remove_inner_ticks : bool, default: False |
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.
If we expect that this will be the desired behavior, what's the cost of making this default to true and add an api change?
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.
we could set it to None
for a release and warn (pass the input to silence it), but that would make it a bit annoying to support multiple versions of Matplotlib (as old versions won't even take the input.
I think if we want to flip the default behavior we should have this option available for a few releases and then go through the above dance when the back-compat story is easier for users.
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 mind adding this as an option, but I pretty strongly feel it should not be the default. I rarely use gridlines, and having the tick nearby makes it easier to quantify by eye.
Parameters | ||
---------- | ||
remove_inner_ticks : bool, default: False | ||
If True, remove the inner ticks as well (not only tick labels). |
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.
needs a versionadded
I think?
assert tick.tick1line.get_visible() == visible | ||
for ax, y_visible, in zip(axs, y_visible): | ||
for tick in ax.yaxis.get_major_ticks(): | ||
assert tick.tick1line.get_visible() == visible |
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 am very confused by coverage claiming this line is not run, the only thing that makes sense is if in every case where we test this ax.yaxis.get_major_ticks()
is an empty list?
Do we need to force a draw at the top of this checker?
I think it's a good idea and have resigned myself to the fact that the very long keyword argument name makes sense. |
Note that if you call |
I'll think about this a bit more. - Maybe this is a reasonable extension (If I want to configure tick label visibility, I may optionally want the same for the ticks themselves. Maybe we need something fundamentally better to configure ticks, ticklabels and spines on grid layouts. |
Given
I'm going to push this to 3.8 unless @timhoffm disagrees. |
I've undrafted the original proposal
Having thought about it: A second method And yes, while sharing axes already gets us the outer labelling, it's still ok to call One could imagine more fundametal label and tick configuration layouts, but that'd be a bigger cake. Given the simplicity of this extension, I don't have any concerns complicating API or reducing maintainability with the suggested change.
That's going too far. |
I think vanishingly few people use label_outer - it's not that useful without sharex/y and sharex/y, which basically do what label_outer does. I think this new feature, which is genuinely useful, is going to be hard to find. |
``label_outer(remove_inner_ticks=True)``. | ||
|
||
|
||
.. plot:: |
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 probably needs an example in the docs somewhere as well? Perhaps also mention at https://matplotlib.org/devdocs/users/explain/axes/axes_ticks.html#styling-ticks-tick-parameters?
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 plan to use it in #24379
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 is very discoverable, but doesn't hurt anything.
Edit: Ok found out what's wrong. I messed up the rebase so that the branch was identical to main, and force-pushed that. Apparently, because nothing is to do here, Github then closes the PR and claims that it's been merged. 🙄 Something is very broken here on GitHub. In contrast to what the page is claiming I did not close this PR, and the commit is also not on master. |
Up to now `label_outer()`, only affects tick labels, but not ticks. This introduces an optional parameter `remove_inner_ticks`, which removes the inner ticks if the corresponding tick labels are removed.
Up to now
label_outer()
, only affects tick labels, but not ticks. This introduces an optional parameterremove_inner_ticks
, which removes the inner ticks if the corresponding tick labels are removed.Example / Motivation:
It's quite cumbersome to remove the ticks as well (same logic as a for the tick labels).
with
ax.label_outer(remove_inner_ticks=True)
this becomes trivial