python画图字体加粗命令
时间: 2023-12-05 18:51:35 浏览: 272
在 Python 中使用 Matplotlib 库绘图时,可以通过设置字体参数来控制字体加粗。
具体命令如下:
```python
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
# 创建字体对象
font = FontProperties(weight='bold')
# 绘制图形
plt.plot([1, 2, 3], [4, 5, 6])
# 设置 x 轴标签字体加粗
plt.xlabel('x轴标签', fontproperties=font)
# 设置 y 轴标签字体加粗
plt.ylabel('y轴标签', fontproperties=font)
# 显示图形
plt.show()
```
其中 `FontProperties` 类的 `weight` 参数可以设置字体加粗程度,可选值包括 `'normal'`(普通字体)、`'bold'`(加粗字体)等。
阅读全文
相关推荐











