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

Skip to content

Commit 7ded0f2

Browse files
authored
Merge pull request #18528 from anntzer/minimumdescent
Deprecate TextArea minimumdescent.
2 parents f4982f1 + e4f875a commit 7ded0f2

File tree

6 files changed

+22
-31
lines changed

6 files changed

+22
-31
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*minimumdescent* parameter/property of ``TextArea``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
`.offsetbox.TextArea` has behaved as if *minimumdescent* was always True
4+
(regardless of the value to which it was set) since Matplotlib 1.3, so the
5+
parameter/property is deprecated.

examples/misc/anchored_artists.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
class AnchoredText(AnchoredOffsetbox):
2222
def __init__(self, s, loc, pad=0.4, borderpad=0.5,
2323
prop=None, frameon=True):
24-
self.txt = TextArea(s, minimumdescent=False)
24+
self.txt = TextArea(s)
2525
super().__init__(loc, pad=pad, borderpad=borderpad,
2626
child=self.txt, prop=prop, frameon=frameon)
2727

@@ -93,13 +93,10 @@ def __init__(self, transform, size, label, loc,
9393
"""
9494
self.size_bar = AuxTransformBox(transform)
9595
self.size_bar.add_artist(Line2D([0, size], [0, 0], color="black"))
96-
97-
self.txt_label = TextArea(label, minimumdescent=False)
98-
96+
self.txt_label = TextArea(label)
9997
self._box = VPacker(children=[self.size_bar, self.txt_label],
10098
align="center",
10199
pad=0, sep=sep)
102-
103100
super().__init__(loc, pad=pad, borderpad=borderpad,
104101
child=self._box, prop=prop, frameon=frameon)
105102

examples/text_labels_and_annotations/demo_annotation_box.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
ax.plot(xy[0], xy[1], ".r")
2727

2828
# Annotate the 1st position with a text box ('Test 1')
29-
offsetbox = TextArea("Test 1", minimumdescent=False)
29+
offsetbox = TextArea("Test 1")
3030

3131
ab = AnnotationBbox(offsetbox, xy,
3232
xybox=(-20, 40),
@@ -36,7 +36,7 @@
3636
ax.add_artist(ab)
3737

3838
# Annotate the 1st position with another text box ('Test')
39-
offsetbox = TextArea("Test", minimumdescent=False)
39+
offsetbox = TextArea("Test")
4040

4141
ab = AnnotationBbox(offsetbox, xy,
4242
xybox=(1.02, xy[1]),

lib/matplotlib/legend.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -755,8 +755,7 @@ def _init_legend_box(self, handles, labels, markerfirst=True):
755755
handle_list.append(None)
756756
else:
757757
textbox = TextArea(lab, textprops=label_prop,
758-
multilinebaseline=True,
759-
minimumdescent=True)
758+
multilinebaseline=True)
760759
handlebox = DrawingArea(width=self.handlelength * fontsize,
761760
height=height,
762761
xdescent=0., ydescent=descent)
@@ -790,12 +789,6 @@ def _init_legend_box(self, handles, labels, markerfirst=True):
790789
children=[h, t] if markerfirst else [t, h],
791790
align="baseline")
792791
for h, t in handles_and_labels[i0:i0 + di]]
793-
# minimumdescent=False for the text of the last row of the column
794-
if markerfirst:
795-
itemBoxes[-1].get_children()[1].set_minimumdescent(False)
796-
else:
797-
itemBoxes[-1].get_children()[0].set_minimumdescent(False)
798-
799792
# pack columnBox
800793
alignment = "baseline" if markerfirst else "right"
801794
columnbox.append(VPacker(pad=0,

lib/matplotlib/offsetbox.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,8 @@ class TextArea(OffsetBox):
775775
width and height of the TextArea instance is the width and height of its
776776
child text.
777777
"""
778+
779+
@cbook._delete_parameter("3.4", "minimumdescent")
778780
def __init__(self, s,
779781
textprops=None,
780782
multilinebaseline=None,
@@ -794,8 +796,9 @@ def __init__(self, s,
794796
If `True`, baseline for multiline text is adjusted so that it is
795797
(approximately) center-aligned with singleline text.
796798
797-
minimumdescent : bool, optional
798-
If `True`, the box has a minimum descent of "p".
799+
minimumdescent : bool, default: True
800+
If `True`, the box has a minimum descent of "p". This is now
801+
effectively always True.
799802
"""
800803
if textprops is None:
801804
textprops = {}
@@ -835,16 +838,20 @@ def get_multilinebaseline(self):
835838
"""
836839
return self._multilinebaseline
837840

841+
@cbook.deprecated("3.4")
838842
def set_minimumdescent(self, t):
839843
"""
840844
Set minimumdescent.
841845
842846
If True, extent of the single line text is adjusted so that
843-
it has minimum descent of "p"
847+
its descent is at least the one of the glyph "p".
844848
"""
849+
# The current implementation of Text._get_layout always behaves as if
850+
# this is True.
845851
self._minimumdescent = t
846852
self.stale = True
847853

854+
@cbook.deprecated("3.4")
848855
def get_minimumdescent(self):
849856
"""
850857
Get minimumdescent.
@@ -894,16 +901,8 @@ def get_extent(self, renderer):
894901
yd_new = 0.5 * h - 0.5 * (h_ - d_)
895902
self._baseline_transform.translate(0, yd - yd_new)
896903
yd = yd_new
897-
898904
else: # single line
899-
900905
h_d = max(h_ - d_, h - yd)
901-
902-
if self.get_minimumdescent():
903-
# To have a minimum descent, i.e., "l" and "p" have same
904-
# descents.
905-
yd = max(yd, d_)
906-
907906
h = h_d + yd
908907

909908
ha = self._text.get_horizontalalignment()
@@ -1301,7 +1300,7 @@ def __init__(self, s, loc, pad=0.4, borderpad=0.5, prop=None, **kwargs):
13011300
raise ValueError(
13021301
'Mixing verticalalignment with AnchoredText is not supported.')
13031302

1304-
self.txt = TextArea(s, textprops=prop, minimumdescent=False)
1303+
self.txt = TextArea(s, textprops=prop)
13051304
fp = self.txt._text.get_fontproperties()
13061305
super().__init__(
13071306
loc, pad=pad, borderpad=borderpad, child=self.txt, prop=fp,

lib/mpl_toolkits/axes_grid1/anchored_artists.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,10 +337,7 @@ def __init__(self, transform, size, label, loc,
337337
else:
338338
textprops = {'color': color, 'fontproperties': fontproperties}
339339

340-
self.txt_label = TextArea(
341-
label,
342-
minimumdescent=False,
343-
textprops=textprops)
340+
self.txt_label = TextArea(label, textprops=textprops)
344341

345342
if label_top:
346343
_box_children = [self.txt_label, self.size_bar]

0 commit comments

Comments
 (0)