'matplotlib: values for the (xx-small, x-small, small, medium, large, x-large, xx-large, larger, smaller) special sizes

The matplotlibrc sample file states that:

## The font.size property is the default font size for text, given in pts.
## 10 pt is the standard value.
##
## Note that font.size controls default text sizes.  To configure
## special text sizes tick labels, axes, labels, title, etc, see the rc
## settings for axes and ticks.  Special text sizes can be defined
## relative to font.size, using the following values: xx-small, x-small,
## small, medium, large, x-large, xx-large, larger, or smaller

What are the equivalent values in pts for those "special text sizes"?



Solution 1:[1]

You can also compute the absolute font sizes yourself very easily

import matplotlib as mpl
import matplotlib.pyplot as plt

fig, ax = plt.subplots()

t = ax.text(0.5, 0.5, 'Text')

fonts = ['xx-small', 'x-small', 'small', 'medium', 'large', 
         'x-large', 'xx-large', 'larger', 'smaller']

for font in fonts:
    t.set_fontsize(font)
    print (font, round(t.get_fontsize(), 2))

plt.close()    

Output

xx-small 5.79
x-small 6.94
small 8.33
medium 10.0
large 12.0
x-large 14.4
xx-large 17.28
larger 12.0
smaller 8.33

Solution 2:[2]

I think these are scaling as in relative sizing, see documentation/code here and here:

size: Either an relative value of 'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large' or an absolute font size, e.g., 12

font_scalings = {
    'xx-small' : 0.579,
    'x-small'  : 0.694,
    'small'    : 0.833,
    'medium'   : 1.0,
    'large'    : 1.200,
    'x-large'  : 1.440,
    'xx-large' : 1.728,
    'larger'   : 1.2,
    'smaller'  : 0.833,
    None       : 1.0}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sheldore
Solution 2