Skip to content

Commit 9276ca7

Browse files
authored
Merge pull request #5283 from will-am/plot_to_file
Support saving figure to file
2 parents dfe851a + 38f10ae commit 9276ca7

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

python/paddle/v2/plot/plot.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def append(self, title, step, value):
5656
assert isinstance(data, PlotData)
5757
data.append(step, value)
5858

59-
def plot(self):
59+
def plot(self, path=None):
6060
if self.__plot_is_disabled__():
6161
return
6262

@@ -68,8 +68,11 @@ def plot(self):
6868
titles.append(title)
6969
self.plt.plot(data.step, data.value)
7070
self.plt.legend(titles, loc='upper left')
71-
self.display.clear_output(wait=True)
72-
self.display.display(self.plt.gcf())
71+
if path is None:
72+
self.display.clear_output(wait=True)
73+
self.display.display(self.plt.gcf())
74+
else:
75+
self.plt.savefig(path)
7376
self.plt.gcf().clear()
7477

7578
def reset(self):

0 commit comments

Comments
 (0)