matplotlib_conf.py 664 B

123456789101112131415161718
  1. class ConfigMatplotlibRelease:
  2. """ Matplotlib 相关配置 """
  3. matplotlib_font = "SimHei"
  4. matplotlib_font_dict = dict(family=matplotlib_font)
  5. ConfigMatplotlib = ConfigMatplotlibRelease
  6. try:
  7. import matplotlib.font_manager as fm
  8. except ImportError:
  9. pass
  10. else:
  11. if ConfigMatplotlib.matplotlib_font not in [f.name for f in fm.fontManager.ttflist]:
  12. print(f"请安装 {ConfigMatplotlib.matplotlib_font} 字体, 字体列表: {fm.fontManager.ttflist}")
  13. exit(1)
  14. fm.rcParams["font.sans-serif"] = [ConfigMatplotlib.matplotlib_font] # 配置中文字体
  15. fm.rcParams["axes.unicode_minus"] = False # 解决负号变豆腐块