Skip to content

Commit b132b5b

Browse files
authored
Merge pull request #30440 from DominikStiller/relative-font-sizes
Document relative font sizes
2 parents 1c3e043 + 2e98ce4 commit b132b5b

File tree

6 files changed

+32
-10
lines changed

6 files changed

+32
-10
lines changed

galleries/examples/pie_and_polar_charts/pie_features.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
fig, ax = plt.subplots()
109109

110110
ax.pie(sizes, labels=labels, autopct='%.0f%%',
111-
textprops={'size': 'smaller'}, radius=0.5)
111+
textprops={'size': 'small'}, radius=0.5)
112112
plt.show()
113113

114114
# %%

galleries/users_explain/text/text_props.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
picker [None|float|bool|callable]
3535
position (x, y)
3636
rotation [ angle in degrees | ``'vertical'`` | ``'horizontal'`` ]
37-
size or fontsize [ size in points | relative size, e.g., ``'smaller'``, ``'x-large'`` ]
37+
size or fontsize [ size in points | relative size, e.g., ``'small'``, ``'x-large'`` ]
3838
style or fontstyle [ ``'normal'`` | ``'italic'`` | ``'oblique'`` ]
3939
text string or anything printable with '%s' conversion
4040
transform `~matplotlib.transforms.Transform` subclass
@@ -48,6 +48,9 @@
4848
========================== ======================================================================================================================
4949
5050
51+
Text alignment
52+
==============
53+
5154
You can lay out text with the alignment arguments
5255
``horizontalalignment``, ``verticalalignment``, and
5356
``multialignment``. ``horizontalalignment`` controls whether the x
@@ -69,8 +72,8 @@
6972
import matplotlib.patches as patches
7073

7174
# build a rectangle in axes coords
72-
left, width = .25, .5
73-
bottom, height = .25, .5
75+
left, width = 0.25, 0.5
76+
bottom, height = 0.25, 0.5
7477
right = left + width
7578
top = bottom + height
7679

@@ -144,6 +147,25 @@
144147
plt.show()
145148

146149
# %%
150+
# Relative font sizes
151+
# ===================
152+
#
153+
# Font sizes can be specified in points, or as a string that indicates the size
154+
# relative to the default font size. The following are valid values for relative font sizes:
155+
#
156+
# ==================== ================================
157+
# Relative font size Scaling of default font size
158+
# ==================== ================================
159+
# xx-small 0.579
160+
# x-small 0.694
161+
# small 0.833
162+
# medium 1.000
163+
# large 1.200
164+
# x-large 1.440
165+
# xx-large 1.728
166+
# ==================== ================================
167+
#
168+
#
147169
# ==============
148170
# Default Font
149171
# ==============

lib/matplotlib/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,7 @@ def rc(group, **kwargs):
10241024
10251025
font = {'family' : 'monospace',
10261026
'weight' : 'bold',
1027-
'size' : 'larger'}
1027+
'size' : 'large'}
10281028
rc('font', **font) # pass in the font dict as kwargs
10291029
10301030
This enables you to easily switch between several configurations. Use

lib/matplotlib/contour.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def clabel(self, levels=None, *,
7676
a subset of ``cs.levels``. If not given, all levels are labeled.
7777
7878
fontsize : str or float, default: :rc:`font.size`
79-
Size in points or relative size e.g., 'smaller', 'x-large'.
79+
Size in points or relative size e.g., 'small', 'x-large'.
8080
See `.Text.set_size` for accepted string values.
8181
8282
colors : :mpltype:`color` or colors or None, default: None

lib/matplotlib/mpl-data/matplotlibrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@
243243
##
244244
## The font.variant property has two values: normal or small-caps. For
245245
## TrueType fonts, which are scalable fonts, small-caps is equivalent
246-
## to using a font size of 'smaller', or about 83 % of the current font
246+
## to using a font size of 'small', or about 83 % of the current font
247247
## size.
248248
##
249249
## The font.weight property has effectively 13 values: normal, bold,
@@ -263,7 +263,7 @@
263263
## special text sizes tick labels, axes, labels, title, etc., see the rc
264264
## settings for axes and ticks. Special text sizes can be defined
265265
## relative to font.size, using the following values: xx-small, x-small,
266-
## small, medium, large, x-large, xx-large, larger, or smaller
266+
## small, medium, large, x-large, xx-large
267267

268268
#font.family: sans-serif
269269
#font.style: normal

lib/matplotlib/mpl-data/stylelib/classic.mplstyle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ hist.bins : 10
6161
#
6262
# The font.variant property has two values: normal or small-caps. For
6363
# TrueType fonts, which are scalable fonts, small-caps is equivalent
64-
# to using a font size of 'smaller', or about 83% of the current font
64+
# to using a font size of 'small', or about 83% of the current font
6565
# size.
6666
#
6767
# The font.weight property has effectively 13 values: normal, bold,
@@ -86,7 +86,7 @@ font.stretch : normal
8686
# special text sizes tick labels, axes, labels, title, etc, see the rc
8787
# settings for axes and ticks. Special text sizes can be defined
8888
# relative to font.size, using the following values: xx-small, x-small,
89-
# small, medium, large, x-large, xx-large, larger, or smaller
89+
# small, medium, large, x-large, xx-large
9090
font.size : 12.0
9191
font.serif : DejaVu Serif, New Century Schoolbook, Century Schoolbook L, Utopia, ITC Bookman, Bookman, Nimbus Roman No9 L, Times New Roman, Times, Palatino, Charter, serif
9292
font.sans-serif: DejaVu Sans, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif

0 commit comments

Comments
 (0)