import glob
import time
import sys
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
mpl.use('Agg')
##plt.use('Agg') 可以解决DISPLAY variable
……
ictrue =(os.path.join(out+"/"+ 'ROC.png'))
fig = plt.gcf()
fig.savefig(pictrue, format='png')
服务器重启后无法连接Xmanager,报错信息:
java.awt.AWTError: Can't connect to X11 window server using 'localhost:12.0' as the value of the DISPLAY variable
python 无法保存图片,增加上面mpl.use('Agg') 即可解决!
网友评论