matplotlib无法显示中文解决方法
Created At :
Count:128
Views 👀 :
import os
from matplotlib import pyplot as plt import matplotlib as mpl from matplotlib.font_manager import FontProperties
font=FontProperties(fname=r'/data/env_env/python/lib/python3.8/site-packages/matplotlib/mpl-data/fonts/ttf/simabs.ttf') def create_image(save_path, text): fig = plt.figure(figsize=(10, 1.25)) fig.text(0.5, 0.5, u'{}'.format(text), horizontalalignment='center', verticalalignment='center', fontsize=15,fontproperties=font) plt.savefig(save_path) plt.close()
|