跟随这个例子
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()我得到了这个输出:

为什么我的标签正常的重量,而文档显示这应该创建粗体字母A,B,C,D
我也收到这样的警告:
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.ttfOP分辨率
Sep 15, 2013 matplotlib的一个问题发布于 2017-04-28 14:47:29
尝试使用weight而不是fontweight。
发布于 2017-04-12 12:04:55
也许试着用这个-
plt.rcParams['axes.labelsize'] = 16
plt.rcParams['axes.labelweight'] = 'bold'在您的程序中,在全局级别上这样做。
发布于 2020-05-01 08:05:10
你问题中的例子在我的机器上有效。因此,您肯定有一个库问题。你考虑过用乳胶做粗体文字吗?这里有一个例子

码
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()https://stackoverflow.com/questions/18812646
复制相似问题