图片打印加上中文

master
wangchunlin 2 years ago
parent facf6dfc25
commit 70c884307b

Binary file not shown.

@ -10,13 +10,18 @@ from sklearn.metrics import precision_score, recall_score, f1_score
from sklearn.utils.class_weight import compute_class_weight
import logging
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
# 控制是否打印的宏定义
PRINT_LOG = True
# 确保 matplotlib 支持中文
plt.rcParams['font.sans-serif'] = ['SimHei'] # 使用黑体
plt.rcParams['axes.unicode_minus'] = False # 解决保存图像时负号 '-' 显示为方块的问题
# 指定字体路径
font_path = os.path.join(os.path.dirname(__file__), 'fonts', 'simhei.ttf')
font_prop = FontProperties(fname=font_path)
# 设置 matplotlib 支持中文
plt.rcParams['font.sans-serif'] = [font_prop.get_name()]
plt.rcParams['axes.unicode_minus'] = False
def log_print(message):
logging.info(message)

Loading…
Cancel
Save