Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 062d54a

Browse files
committed
Text should take up a pixel of window extent when invisible
1 parent 10a0c8f commit 062d54a

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

lib/matplotlib/text.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ def get_window_extent(self, renderer=None, dpi=None):
874874
"""
875875
#return _unit_box
876876
if not self.get_visible():
877-
return Bbox.null()
877+
return Bbox.unit()
878878
if dpi is None:
879879
dpi = self.figure.dpi
880880
if self.get_text() == '':
@@ -1959,7 +1959,7 @@ def get_window_extent(self, renderer=None):
19591959
# This block is the same as in Text.get_window_extent, but we need to
19601960
# set the renderer before calling update_positions().
19611961
if not self.get_visible() or not self._check_xy(renderer):
1962-
return Bbox.null()
1962+
return Bbox.unit()
19631963
if renderer is not None:
19641964
self._renderer = renderer
19651965
if self._renderer is None:
@@ -1977,5 +1977,11 @@ def get_window_extent(self, renderer=None):
19771977

19781978
return Bbox.union(bboxes)
19791979

1980+
def get_tightbbox(self, renderer):
1981+
# docstring inherited
1982+
if not self._check_xy(renderer):
1983+
return Bbox.null()
1984+
return super().get_tightbbox(renderer)
1985+
19801986

19811987
docstring.interpd.update(Annotation=Annotation.__init__.__doc__)

lib/matplotlib/tight_layout.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,8 @@ def auto_adjust_subplotpars(
6868

6969
if ax_bbox_list is None:
7070
ax_bbox_list = [
71-
[ax.get_position(original=True) for ax in subplots]
72-
for subplots in subplot_list
73-
]
74-
ax_bbox_list = [
75-
Bbox.union([
76-
b for b in bbox_list
77-
if np.isfinite(b.width) and np.isfinite(b.height)
78-
and (b.width != 0 or b.height != 0)
79-
])
80-
for bbox_list in ax_bbox_list
81-
]
71+
Bbox.union([ax.get_position(original=True) for ax in subplots])
72+
for subplots in subplot_list]
8273

8374
for subplots, ax_bbox, (num1, num2) in zip(subplot_list,
8475
ax_bbox_list,

0 commit comments

Comments
 (0)