Commit 5959833
committed
BUG: Refresh 3D axis projection before tightbbox to fix constrained layout overlap (GH#31277)
Axis3D.get_tightbbox() read stale tick-label (x, y) positions that were
last set during the previous draw() call. When constrained_layout queries
the bounding boxes before any draw has occurred, the positions are
uninitialised, causing the 3D subplot's reported bbox to be too small.
Adjacent subplots then overlap the 3D tick labels.
Fix: at the start of Axis3D.get_tightbbox(), refresh the projection
matrix (M / invM) via apply_aspect() and get_proj(), then call
self.draw() inside renderer._draw_disabled() to update the tick-label
positions without producing any visible output. The rest of the method
already reads those positions correctly.
Two regression tests are added:
- test_axis_get_tightbbox_before_draw_matches_after_draw: the bbox
returned before any draw() must match the one returned after draw().
- test_constrained_layout_3d_no_overlap_with_subplot_title: with a 3D
subplot above a 2D subplot in constrained_layout, the 3D tight bbox
bottom must not overlap the 2D subplot title.1 parent e9637a6 commit 5959833
3 files changed
Lines changed: 53 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
684 | 684 | | |
685 | 685 | | |
686 | 686 | | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
687 | 707 | | |
688 | 708 | | |
689 | 709 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2780 | 2780 | | |
2781 | 2781 | | |
2782 | 2782 | | |
| 2783 | + | |
| 2784 | + | |
| 2785 | + | |
| 2786 | + | |
| 2787 | + | |
| 2788 | + | |
| 2789 | + | |
| 2790 | + | |
| 2791 | + | |
| 2792 | + | |
| 2793 | + | |
| 2794 | + | |
| 2795 | + | |
| 2796 | + | |
| 2797 | + | |
| 2798 | + | |
| 2799 | + | |
| 2800 | + | |
| 2801 | + | |
| 2802 | + | |
| 2803 | + | |
| 2804 | + | |
| 2805 | + | |
| 2806 | + | |
| 2807 | + | |
| 2808 | + | |
| 2809 | + | |
| 2810 | + | |
| 2811 | + | |
| 2812 | + | |
| 2813 | + | |
| 2814 | + | |
| 2815 | + | |
2783 | 2816 | | |
2784 | 2817 | | |
2785 | 2818 | | |
| |||
0 commit comments