提交 38f10aea 编写于 作者: W wangmeng28

Add plot to file

上级 2e74cf46
...@@ -56,7 +56,7 @@ class Ploter(object): ...@@ -56,7 +56,7 @@ class Ploter(object):
assert isinstance(data, PlotData) assert isinstance(data, PlotData)
data.append(step, value) data.append(step, value)
def plot(self): def plot(self, path=None):
if self.__plot_is_disabled__(): if self.__plot_is_disabled__():
return return
...@@ -68,8 +68,11 @@ class Ploter(object): ...@@ -68,8 +68,11 @@ class Ploter(object):
titles.append(title) titles.append(title)
self.plt.plot(data.step, data.value) self.plt.plot(data.step, data.value)
self.plt.legend(titles, loc='upper left') self.plt.legend(titles, loc='upper left')
if path is None:
self.display.clear_output(wait=True) self.display.clear_output(wait=True)
self.display.display(self.plt.gcf()) self.display.display(self.plt.gcf())
else:
self.plt.savefig(path)
self.plt.gcf().clear() self.plt.gcf().clear()
def reset(self): def reset(self):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册