You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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).
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:
(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?
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.
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.
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.
The use case that springs to mind for me is the third example here, where we add a bunch of spaces to move the month labels to the right. Ideally we could set the horizontal_alignment to left instead
# note the extra spaces in the label to align the month label inside the month.# Note that this could have been done by changing ``bymonthday`` above as well:sec.xaxis.set_major_formatter(mdates.DateFormatter(' %b'))
The use case that springs to mind for me is the third example here, where we add a bunch of spaces to move the month labels to the right. Ideally we could set the horizontal_alignment to left instead
I don't think this would even help here. The day tick labels are center-aligned. The spacing emulates left-alignment to te day tick labels. but a possible tick_params(horizontalalignment='left') would left-align to the tick not to the day tick label. Alternatively left aligning bot the day label and the month label wrt. to the tick is possibly also not desirable here.
given, #20644 (comment) and #20644 (comment) i tend towards not implementing label alignment. Are there compelling use cases that still need to set this? If so, is the per-text alignment logic the right one or would one rather need a global function similar to align_titels \ align_labels?
Activity
[-]add label alignement to tick_params[/-][+]add label alignment to tick_params[/+]timhoffm commentedon Aug 19, 2021
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 commentedon Aug 19, 2021
I totally agree w/ you on an automagical angle alignment as that's probably a common use case.
story645 commentedon 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:
matplotlib/lib/matplotlib/axes/_base.py
Line 3358 in 4f5cacf
matplotlib/lib/matplotlib/axis.py
Line 850 in 4f5cacf
matplotlib/lib/matplotlib/axis.py
Line 35 in 4f5cacf
(ETA: probably in 3,2,1 order) + tests for all the new kwargs (which I think means image tests?)
QuLogic commentedon Jul 15, 2022
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 commentedon Jun 7, 2023
I've heard the
setpexcuse 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 thatsetpis 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_paramsand.set_tick_paramsmethods? Is this just not implemented yet or are there major obstacles?timhoffm commentedon 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 commentedon 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 commentedon Apr 20, 2025
Hi @timhoffm ! I'm Evelyn, and am interested in helping resolve this issue. Can me and my team work on this?
timhoffm commentedon Apr 21, 2025
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.
Label Aligment Issue matplotlib#20644 with Horizontal Support matplot…
rcomer commentedon Jun 2, 2025
The use case that springs to mind for me is the third example here, where we add a bunch of spaces to move the month labels to the right. Ideally we could set the horizontal_alignment to left instead
https://matplotlib.org/stable/gallery/ticks/multilevel_ticks.html
Admittedly this is a pretty specialised case.
rcomer commentedon Jun 19, 2025
We should remove the GFI label while we decide if we still want this.
timhoffm commentedon Aug 24, 2025
I don't think this would even help here. The day tick labels are center-aligned. The spacing emulates left-alignment to te day tick labels. but a possible
tick_params(horizontalalignment='left')would left-align to the tick not to the day tick label. Alternatively left aligning bot the day label and the month label wrt. to the tick is possibly also not desirable here.repeating #30009 (comment):