在linux终端保存matplotlib绘制的图像

import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt

fig, ax = plt.subplots()
bar_1 = ax.bar(x , np.array(finall_info[0]),  width=width, label=str(0), color='r')
bar_2 = ax.bar(x + width, np.array(finall_info[1]),  width=width, label=str(1), color='y')

ax.set_ylabel('Acc')
ax.set_title('Acc of Different iters')
ax.set_xticklabels(labels_to_show)
ax.legend()

fig.tight_layout()
plt.savefig(save_name)

猜你喜欢

转载自blog.csdn.net/qq_29007291/article/details/115954137