Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a63dc33

Browse filesBrowse files
committed
FIX: Axis.set_in_layout respected
1 parent 30f803b commit a63dc33
Copy full SHA for a63dc33

File tree

Expand file treeCollapse file tree

2 files changed

+22
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+22
-1
lines changed

‎lib/matplotlib/axis.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axis.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1362,7 +1362,7 @@ def get_tightbbox(self, renderer=None, *, for_layout_only=False):
13621362
collapsed to near zero. This allows tight/constrained_layout to ignore
13631363
too-long labels when doing their layout.
13641364
"""
1365-
if not self.get_visible():
1365+
if not self.get_visible() or for_layout_only and not self.get_in_layout():
13661366
return
13671367
if renderer is None:
13681368
renderer = self.figure._get_renderer()

‎lib/matplotlib/tests/test_axis.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axis.py
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,24 @@ def test_tick_labelcolor_array():
88
# Smoke test that we can instantiate a Tick with labelcolor as array.
99
ax = plt.axes()
1010
XTick(ax, 0, labelcolor=np.array([1, 0, 0, 1]))
11+
12+
13+
def test_axis_not_in_layout():
14+
fig1, (ax1_left, ax1_right) = plt.subplots(ncols=2, layout='constrained')
15+
fig2, (ax2_left, ax2_right) = plt.subplots(ncols=2, layout='constrained')
16+
17+
# 100 label overlapping the end of the axis
18+
ax1_left.set_xlim([0, 100])
19+
# 100 label not overlapping the end of the axis
20+
ax2_left.set_xlim([0, 120])
21+
22+
for ax in ax1_left, ax2_left:
23+
ax.set_xticks([0, 100])
24+
ax.xaxis.set_in_layout(False)
25+
26+
for fig in fig1, fig2:
27+
fig.draw_without_rendering()
28+
29+
# Positions should not be affected by overlapping 100 label
30+
assert ax1_left.get_position().bounds == ax2_left.get_position().bounds
31+
assert ax1_right.get_position().bounds == ax2_right.get_position().bounds

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.