运行时依赖
无特殊依赖
安装命令
点击复制官方npx clawhub@latest install matplotlib-chinese-font
镜像加速npx clawhub@latest install matplotlib-chinese-font --registry https://cn.longxiaskill.com镜像同步中
技能文档
简介
配置 matplotlib 中使用中文字体,解决中文字符图表显示乱码问题。用法
- 安装必要依赖(如果未安装)
# 示例依赖安装命令,实际命令可能有所不同
pip install matplotlib
- 配置并使用中文字体
import matplotlib.pyplot as plt
# 示例:配置使用 '宋体' 字体
plt.rcParams['font.sans-serif'] = ['宋体']
plt.rcParams['axes.unicode_minus'] = False
# 示例图表绘制
plt.plot([1, 2, 3])
plt.title('中文标题示例')
plt.show()
注意
- 确保系统中有所选中文字体。
- 根据实际需求选择合适的中文字体。