首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何解析UserWarning: findfont:无法与:family=Bitstream Vera Sans匹配

如何解析UserWarning: findfont:无法与:family=Bitstream Vera Sans匹配
EN

Stack Overflow用户
提问于 2013-09-15 12:57:52
回答 5查看 50.4K关注 0票数 27

跟随这个例子

代码语言:javascript
复制
import numpy as np
import matplotlib.pyplot as plt

fig = plt.figure()
for i, label in enumerate(('A', 'B', 'C', 'D')):
    ax = fig.add_subplot(2,2,i+1)
    ax.text(0.05, 0.95, label, transform=ax.transAxes,
      fontsize=16, fontweight='bold', va='top')

plt.show()

我得到了这个输出:

为什么我的标签正常的重量,而文档显示这应该创建粗体字母ABCD

我也收到这样的警告:

代码语言:javascript
复制
Warning (from warnings module):
File "C:\Python27\lib\site-packages\matplotlib\font_manager.py", line 1228
UserWarning)
UserWarning: findfont: Could not match :family=Bitstream Vera Sans:style=italic:variant=normal:weight=bold:stretch=normal:size=x-small. Returning C:\Python27\lib\site-packages\matplotlib\mpl-data\fonts\ttf\Vera.ttf

OP分辨率

EN

回答 5

Stack Overflow用户

发布于 2017-04-28 14:47:29

尝试使用weight而不是fontweight

票数 14
EN

Stack Overflow用户

发布于 2017-04-12 12:04:55

也许试着用这个-

代码语言:javascript
复制
plt.rcParams['axes.labelsize'] = 16
plt.rcParams['axes.labelweight'] = 'bold'

在您的程序中,在全局级别上这样做。

票数 7
EN

Stack Overflow用户

发布于 2020-05-01 08:05:10

你问题中的例子在我的机器上有效。因此,您肯定有一个库问题。你考虑过用乳胶做粗体文字吗?这里有一个例子

代码语言:javascript
复制
import numpy as np
import matplotlib.pyplot as plt

fig, axs = plt.subplots(3, 1)
ax0, ax1, ax2 = axs

ax0.text(0.05, 0.95, 'example from question',
        transform=ax0.transAxes, fontsize=16, fontweight='bold', va='top')
ax1.text(0.05, 0.8, 'you can try \\textbf{this} using \\LaTeX', usetex=True,
        transform=ax1.transAxes, fontsize=16, va='top')
ax2.text(0.05, 0.95,
         'or $\\bf{this}$ (latex math mode with things like '
         '$x_\mathrm{test}^2$)',
        transform=ax2.transAxes, fontsize=10, va='top')

plt.show()
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18812646

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档