GeezerVison is showing github.com — Switch AxisArtist to use standard tick directions. by anntzer · Pull Request #19102 · matplotlib/matplotlib
Conversation
i.e. defaulting to "out". Also support "inout".
I had this patch lying around, and am only posting it because of #19101 (which this implements). Although tests pass, there are a few remaining points:
-
The default change (to "out"), as well as the new feature, have to be documented.
-
There is one point in the old implementation which I do not understand:
if self._ticklabel_add_angle != self._axislabel_add_angle:
if ((self.major_ticks.get_visible() # ???
and not self.major_ticks.get_tick_out())
or (self.minor_ticks.get_visible()
and not self.major_ticks.get_tick_out())):
axislabel_pad = self.major_ticks._ticksize
else:
axislabel_pad = 0
I don't understand the conditions in which the pad are zero or nonzero, and don't know either whether the second branch of the or should actually use minor_ticks twice instead of minor_ticks and then major_ticks. Thus I don't know either how the check should be adapted for the "inout" case.
- I feel like "out" ticks actually look quite ugly when they are kept tangential to the gridline, as can be seen e.g. with demo_curvelinear_grid, which now gives

I feel like it would actually look much nicer to have ticks perpendicular to the spines?
attn @jasondet I guess, feel free to pick up the patch.
PR Summary
PR Checklist
- Has pytest style unit tests (and
pytest passes).
- Is Flake 8 compliant (run
flake8 on changed files to check).
- New features are documented, with examples if plot related.
- Documentation is sphinx and numpydoc compliant (the docs should build without error).
- Conforms to Matplotlib style conventions (install
flake8-docstrings and run flake8 --docstring-convention=all).
- New features have an entry in
doc/users/next_whats_new/ (follow instructions in README.rst there).
- API changes documented in
doc/api/next_api_changes/ (follow instructions in README.rst there).
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
i.e. defaulting to "out". Also support "inout".
Would perpendicular work better for "out"? see e.g.
demo_curvelinear_grid.
leejjoon
commented
Nov 16, 2022
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
- There is one point in the old implementation which I do not understand:
if self._ticklabel_add_angle != self._axislabel_add_angle:
if ((self.major_ticks.get_visible() # ???
and not self.major_ticks.get_tick_out())
or (self.minor_ticks.get_visible()
and not self.major_ticks.get_tick_out())):
axislabel_pad = self.major_ticks._ticksize
else:
axislabel_pad = 0
My recollection is that this is to test if the axislabel and the ticklabels are on the same side. If self._ticklabel_add_angle != self._axislabel_add_angle is True, it means that they on different side. In this case, we only need to check if the ticks are on the same side as the axislabel. Also, the second branch of the or should use minor_ticks twice.

|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
I just realized that this is a two-year old PR. It would be still good if this can be merged after some more fix. I can work on it if that is desired.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@leejjoon Feel free to pick it up; it was essentially a proof of concept in reply to #19101.
One thing I would suggest to change, though, is the orientation of ticks with the "out" direction: as noted above, I think it would look nicer if they were actually perpendicular to the box, rather than tangential with the gridline. (Inwards ticks can stay tangential.)
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
One thing I would suggest to change, though, is the orientation of ticks with the "out" direction: as noted above, I think it would look nicer if they were actually perpendicular to the box, rather than tangential with the gridline. (Inwards ticks can stay tangential.)
For this, I'd like to introduce tickangle_mode. For now, it's argument could be 'auto' (or None), 'normal', and 'parallel'. 'normal' is for perpendicular to the box, 'parallel' is for parallel to gridlines, and 'auto' is 'normal' only if tickdir is 'out'.
However, I don't think these are good choice of option names. Any recommendation?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Here are some exanples. For the floating_axis, I enforced "parallel" mode.


|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
I would perhaps call this tick_orientation={"parallel", "normal", "auto"}. Perhaps @timhoffm can chime in?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Actually superseded by #30369 in the end.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|