Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
[Example] Add workaround for tick_top and sharex compatibility (#30219)#30225
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
[Example] Add workaround for tick_top and sharex compatibility (#30219)#30225
Conversation
The failures appear unrelated to this PR, which only adds a new example script. Let me know if you’d like me to rebase or adjust anything! |
Thanks for working on this! However, it does not show up in the documentation:https://output.circle-artifacts.com/output/job/f028b096-7bb3-4c19-86e1-26b205c9a66e/artifacts/0/doc/build/html/gallery/statistics/index.html The reason is that there is no title of the example. Please see some of the other examples how to do that. Also, it would be good if there was a bit context about what this example is showing. Something like "Combining YYY with ZZZ is a common pitfall and this example illustrates how one can work around that". |
Thanks for the helpful feedback! I’ve added a title and a short docstring at the top of the example to ensure it shows up in the gallery. The description also now explains the context specifically how tick_top() behaves unexpectedly with sharex=True, and how this example provides a workaround using tick_params() and label_outer(). |
Thanks for your willingness to contribute! However, I don't think this is going the right direction. First, the current best solution would be#30219 (comment). Second, and more importantly, the discussion in#30219 is going into the direction of enhancing |
Closes#30219
This PR adds a new example script under
examples/statistics/
that demonstrates a practical workaround for usingtick_top()
withsharex=True
in a subplot grid.Background
When using shared x-axes,
tick_top()
does not restore tick labels on the top row because shared axes suppress labels on all but the bottom subplot by default. This results in unintuitive behaviour for users expecting top ticks on the uppermost axes.What This Example Shows
This example:
tick_params(top=True, labeltop=True, bottom=False, labelbottom=False)
on the top row,ax.label_outer()
to hide redundant ticks in the interior,This provides a clean, idiomatic alternative for achieving the intended visual layout.
Tested