python - matplotlib:(xx-small、x-small、small、medium、large、x-large、xx-large、large、smaller)特殊尺寸的值

标签 python matplotlib

matplotlibrc 示例文件指出:

## 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

这些“特殊文字大小”的 pts 等效值是多少?

最佳答案

您也可以很容易地自己计算绝对字体大小

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()    

输出
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

关于python - matplotlib:(xx-small、x-small、small、medium、large、x-large、xx-large、large、smaller)特殊尺寸的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62288898/

相关文章:

python - 在 Twill 中使用正则表达式

python - plt.show() 和 fig.savefig() 的不同绘图大小

python - 将 nltk 图保存到 headless (headless)服务器/虚拟机上的文件

python - 在 Tkinter 中显示 matplotlib 条形图

python - Matplotlib x 轴过度拥挤的标签渲染

python - 将 hdf5 文件组合成单个数据集

python - Tensorflow卷积和numpy卷积的区别

python - 覆盖 pandas KDE 和直方图时正确渲染 y 轴

python - 即使游标关闭,Psycopg 请求也会挂起

python - 使用 matplotlib.animation.FuncAnimation 制作具有周期性边界的多车道高速公路的动画