【问题标题】:Matplotlib font families: using Arno Pro or other fontsMatplotlib 字体系列:使用 Arno Pro 或其他字体
【发布时间】:2013-09-05 20:08:08
【问题描述】:

我正在用 Arno Pro 字体写我的论文,我希望我的图像中的字体(我使用 matplotlib 制作)与我的论文相匹配。 matplotlib 的文档声称:

The font.family property has five values: 'serif' (e.g., Times),
'sans-serif' (e.g., Helvetica), 'cursive' (e.g., Zapf-Chancery),
'fantasy' (e.g., Western), and 'monospace' (e.g., Courier).

是否可以在 matplotlib 的标签中使用 Arno Pro 或其他字体系列?如果有,怎么做?

谢谢。

【问题讨论】:

    标签: fonts matplotlib labels


    【解决方案1】:

    使用font manager 可以找到所有可用的字体:

    import matplotlib.font_manager
    print matplotlib.font_manager.findSystemFonts(fontpaths=None)
    

    这将打印所有可用字体的列表,我找不到 Arno Pro,但也许你可以为它找到一个 .ttf 文件(或类似的东西)然后执行以下操作

    import matplotlib.pylab as plt
    
    plt.rcParams['font.family']='Sawasdee'
    
    mpl.pylab.plot(range(10), mpl.pylab.sin(range(10)))
    mpl.pylab.xlabel("Some crazy font", size=20)
    

    产生:

    注意,我简化了从字体管理器输出中选择了一个名为Sawasdee 的随机文件,因此它可能未安装在您的计算机上并会引发错误。

    显然这种字体也会产生一些错误,所以你必须小心这些,祝你好运!

    【讨论】:

    • 我找到了 Arno Pro 的 .ttf,还有here 是如何使用它的。
    猜你喜欢
    • 2013-09-20
    • 2014-02-02
    • 1970-01-01
    • 2016-03-01
    • 2019-04-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-25
    相关资源
    最近更新 更多