白山市网站建设_网站建设公司_Tailwind CSS_seo优化
2026/1/6 20:57:08 网站建设 项目流程
  1. apt update
  2. apt install -y fonts-wqy-microhei
  3. fc-list | grep -E “WenQuanYi|Noto”
  4. 清楚缓存
importmatplotlibimportosimportshutil# 获取matplotlib缓存目录cache_dir=matplotlib.get_cachedir()print(f"Matplotlib缓存目录:{cache_dir}")# 清空缓存目录ifos.path.exists(cache_dir):foriteminos.listdir(cache_dir):item_path=os.path.join(cache_dir,item)try:ifos.path.isfile(item_path):os.remove(item_path)elifos.path.isdir(item_path):shutil.rmtree(item_path)exceptExceptionase:print(f"清理缓存时出错:{e}")print("✅ 已清除matplotlib字体缓存")
  1. 中文测试
importmatplotlib.pyplotasplt# 配置matplotlib使用文泉驿微米黑字体plt.rcParams['font.sans-serif']=['WenQuanYi Micro Hei']# 对应安装的字体名plt.rcParams['axes.unicode_minus']=False# 解决负号显示为方块的问题# 绘制测试图验证中文显示plt.figure(figsize=(8,4))plt.title("Linux Notebook中文显示测试 - 文泉驿微米黑")# 中文标题plt.xlabel("X轴:测试数据")# 中文X轴标签plt.ylabel("Y轴:数值大小")# 中文Y轴标签plt.plot([1,2,3,4],[10,5,15,8],label="测试曲线(中文图例)")plt.text(2,12,"负号测试:-987.65",fontsize=12)# 测试负号显示plt.legend()# 显示图例plt.grid(True)plt.show()

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询