Skip to content

add label alignment to tick_params #20644

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
story645 opened this issue Jul 14, 2021 · 9 comments · May be fixed by #30009
Open

add label alignment to tick_params #20644

story645 opened this issue Jul 14, 2021 · 9 comments · May be fixed by #30009
Labels
Difficulty: Medium https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues Good first issue Open a pull request against these issues if there are no active ones! New feature topic: text topic: ticks axis labels

Comments

@story645
Copy link
Member

story645 commented Jul 14, 2021

tick_params supports a subset of labeling parameters:

  • labelcolor
  • labelsize
  • label{bottom, top, left, right}
  • labelrotation

Motivated by wanting to swap out plt.setp and use tick_params, and finding the tick_params list kind of arbitrary, I think if labels can be modified via tick_params than a larger set of label parameters should be supported. This would mean adding:

@QuLogic QuLogic changed the title add label alignement to tick_params add label alignment to tick_params Jul 17, 2021
@timhoffm
Copy link
Member

Not sure if that's too much magic, but IMHO tick labels should always "point" to their tick. That would require different alignment depending on the rotation angle.

It could be an option not to expose explicit alignment but automatically choose it depending on the angle. (You could still use setp() if you need full control over all tick properties).

@story645
Copy link
Member Author

I totally agree w/ you on an automagical angle alignment as that's probably a common use case.

@story645
Copy link
Member Author

story645 commented Jul 14, 2022

Labeling good first issue because it seems to have support from at least two devs and is somewhat independent, but medium difficulty because it's kind of involved:

  1. adding more dispatch in
    def tick_params(self, axis='both', **kwargs):
  2. adding more kwarg support to
    def set_tick_params(self, which='major', reset=False, **kw):
  3. modify some methods on the tick class to support the new keywords
    class Tick(martist.Artist):

(ETA: probably in 3,2,1 order) + tests for all the new kwargs (which I think means image tests?)

@story645 story645 added Difficulty: Medium https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues Good first issue Open a pull request against these issues if there are no active ones! labels Jul 14, 2022
@QuLogic
Copy link
Member

QuLogic commented Jul 15, 2022

(which I think means image tests?)

I think it can check [label.get_[vh]a() for label in get_ticklabels()]? (or via some similar new getter API if it gets added.)

@joooeey
Copy link

joooeey commented Jun 7, 2023

(You could still use setp() if you need full control over all tick properties).

I've heard the setp excuse a lot all over this issue tracker and Stackoverflow in many contexts but it has a major flaw: For those of us working with interactive plots, we have to somehow make sure that setp is called after re-drawing when the ticks change.

Can anyone enlighten me what the reason is that we don't provide a mechanism to pass all keyword arguments to the ticks and labels through the various .tick_params and .set_tick_params methods? Is this just not implemented yet or are there major obstacles?

@timhoffm
Copy link
Member

timhoffm commented Jun 7, 2023

This ist mostly "just not implemented". However I except that there can be some corner cases (e.g. the alignment discussion above), where we might want to deviate from simply passing through.

@timhoffm
Copy link
Member

timhoffm commented Dec 9, 2024

While not a replacement, the new rotation modes in #28968 remove the need for explicit alignment control for one of the current most common use cases: fix tick alignment after rotation.

@evelyn-lo
Copy link

Hi @timhoffm ! I'm Evelyn, and am interested in helping resolve this issue. Can me and my team work on this?

@timhoffm
Copy link
Member

Hi @evelyn-lo thanks for your interest. I'm still unclear whether we should support the alignment. If so, it would have the effect as described here, which should explicitly be mentioned as it may not be the obvious behavior.

aydengemz added a commit to aydengemz/matplotlib that referenced this issue May 4, 2025
@aydengemz aydengemz linked a pull request May 4, 2025 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Difficulty: Medium https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues Good first issue Open a pull request against these issues if there are no active ones! New feature topic: text topic: ticks axis labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants