Commit 7b376d5
committed
Fix y-label overlap with tick labels for non-default rotations (#19029)
`YAxis._update_label_position` previously assumed a 90° label rotation
when computing the label's position, so y-labels with other rotations
(e.g. ``rotation=270`` for right-side colorbar labels) could overlap
the tick labels. The label position is now computed from the rendered
label's actual extent, so it sits clear of the tick labels for any
rotation. This implements @jklymak's suggestion in the issue thread of
checking the rendered label extent against the tick labels in
`_update_label_position`.
The fix is a no-op for the default ``rotation=90`` case, so existing
image baselines are unaffected.
Tests added in test_axes.py cover the generic axis-layer fix
(parametrized over 7 rotations × 2 label_positions) plus an
``align_ylabels`` regression that guards against the per-axis overhang
correction breaking sibling alignment when rotations differ. A
colorbar smoke test in test_colorbar.py exercises the original
user-facing symptom from the issue via ``cbar.set_label(...,
rotation=270)``.1 parent 462e6a6 commit 7b376d5
4 files changed
Lines changed: 94 additions & 4 deletions
File tree
- doc/api/next_api_changes/behavior
- lib/matplotlib
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2735 | 2735 | | |
2736 | 2736 | | |
2737 | 2737 | | |
2738 | | - | |
2739 | | - | |
| 2738 | + | |
| 2739 | + | |
| 2740 | + | |
| 2741 | + | |
| 2742 | + | |
| 2743 | + | |
| 2744 | + | |
| 2745 | + | |
| 2746 | + | |
| 2747 | + | |
2740 | 2748 | | |
2741 | 2749 | | |
2742 | 2750 | | |
2743 | 2751 | | |
2744 | | - | |
2745 | | - | |
| 2752 | + | |
| 2753 | + | |
| 2754 | + | |
| 2755 | + | |
| 2756 | + | |
| 2757 | + | |
| 2758 | + | |
2746 | 2759 | | |
2747 | 2760 | | |
2748 | 2761 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9070 | 9070 | | |
9071 | 9071 | | |
9072 | 9072 | | |
| 9073 | + | |
| 9074 | + | |
| 9075 | + | |
| 9076 | + | |
| 9077 | + | |
| 9078 | + | |
| 9079 | + | |
| 9080 | + | |
| 9081 | + | |
| 9082 | + | |
| 9083 | + | |
| 9084 | + | |
| 9085 | + | |
| 9086 | + | |
| 9087 | + | |
| 9088 | + | |
| 9089 | + | |
| 9090 | + | |
| 9091 | + | |
| 9092 | + | |
| 9093 | + | |
| 9094 | + | |
| 9095 | + | |
| 9096 | + | |
| 9097 | + | |
| 9098 | + | |
| 9099 | + | |
| 9100 | + | |
| 9101 | + | |
| 9102 | + | |
| 9103 | + | |
| 9104 | + | |
| 9105 | + | |
| 9106 | + | |
| 9107 | + | |
| 9108 | + | |
| 9109 | + | |
| 9110 | + | |
| 9111 | + | |
| 9112 | + | |
| 9113 | + | |
| 9114 | + | |
| 9115 | + | |
| 9116 | + | |
| 9117 | + | |
| 9118 | + | |
| 9119 | + | |
| 9120 | + | |
9073 | 9121 | | |
9074 | 9122 | | |
9075 | 9123 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
733 | 733 | | |
734 | 734 | | |
735 | 735 | | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
736 | 754 | | |
737 | 755 | | |
738 | 756 | | |
| |||
0 commit comments