Skip to content

Commit ae41b18

Browse files
committed
perf(draw): 中文乱码;每次重新绘制新的图片
1 parent 5243103 commit ae41b18

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pynet/vision/draw.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
import matplotlib.pyplot as plt
88

9+
plt.rcParams['font.sans-serif'] = ['simhei'] # 用来正常显示中文标签
10+
plt.rcParams['axes.unicode_minus'] = False # 用来正常显示负号
11+
912

1013
class Draw(object):
1114

@@ -14,6 +17,7 @@ def __call__(self, values, title='损失图', xlabel='迭代/次', ylabel='损
1417

1518
def forward(self, values, title='损失图', xlabel='迭代/次', ylabel='损失值', save_path='./loss.png'):
1619
assert isinstance(values, list)
20+
f = plt.figure()
1721
plt.title(title)
1822
plt.ylabel(ylabel)
1923
plt.xlabel(xlabel)
@@ -26,6 +30,7 @@ def multi_plot(self, values_list, labels_list, title='损失图', xlabel='迭代
2630
assert isinstance(labels_list, tuple)
2731
assert len(values_list) == len(labels_list)
2832

33+
f = plt.figure()
2934
plt.title(title)
3035
plt.ylabel(ylabel)
3136
plt.xlabel(xlabel)

0 commit comments

Comments
 (0)