2017-01-20 19:51:20 +04:00
|
|
|
import time
|
|
|
|
import matplotlib.pyplot as plt
|
|
|
|
|
|
|
|
|
|
|
|
current_milli_time = lambda: int(round(time.time() * 1000))
|
|
|
|
|
|
|
|
|
|
|
|
def uniquefilename(name):
|
|
|
|
if '.' in name:
|
|
|
|
tmp = name.split('.')
|
|
|
|
return tmp[0] + str(current_milli_time()) + '.' + tmp[1]
|
|
|
|
else:
|
|
|
|
return name + str(current_milli_time())
|
|
|
|
|
|
|
|
|
2017-01-27 14:26:47 +04:00
|
|
|
def showAndSaveImage(fig,file,flag,lgd=None):
|
2017-01-20 19:51:20 +04:00
|
|
|
if flag:
|
|
|
|
plt.show()
|
2017-01-27 14:26:47 +04:00
|
|
|
if lgd is not None:
|
|
|
|
fig.savefig(uniquefilename(file), additional_artists=lgd,bbox_inches='tight') #bbox_extra_artists=(lgd,), )
|
|
|
|
else:
|
|
|
|
fig.savefig(uniquefilename(file))
|
2017-01-20 19:51:20 +04:00
|
|
|
plt.close(fig)
|