diff --git a/plotting.py b/plotting.py index db4df9552ac5cea85595eb44f7ee477c2de4b3b3..be9057e3bf5ab6fd93bdad2f4d8f3a6962fa1108 100644 --- a/plotting.py +++ b/plotting.py @@ -60,8 +60,7 @@ def plot_NN_vs_var_1D(plotname, means, scorefun, var_index, var_range, var_label if var_label is not None: ax.set_xlabel(var_label) ax.set_ylabel("NN output") - fig.savefig(plotname) - plt.close(fig) + save_show(plt, fig, plotname) def plot_NN_vs_var_2D(plotname, means, @@ -134,8 +133,7 @@ def plot_NN_vs_var_2D(plotname, means, ax.set_xlabel(varx_label) if vary_label is not None: ax.set_ylabel(vary_label) - fig.savefig(plotname) - plt.close(fig) + save_show(plt, fig, plotname) def plot_NN_vs_var_2D_all(plotname, model, means, @@ -233,8 +231,7 @@ def plot_NN_vs_var_2D_all(plotname, model, means, cb.ax.xaxis.set_ticks_position('top') cb.ax.xaxis.set_label_position('top') - fig.savefig(plotname, bbox_inches='tight') - plt.close(fig) + save_show(plt, fig, plotname, bbox_inches='tight') def plot_hist_2D(plotname, xedges, yedges, hist, varx_label=None, vary_label=None, log=False, zlabel="# of events"): @@ -252,9 +249,7 @@ def plot_hist_2D(plotname, xedges, yedges, hist, varx_label=None, vary_label=Non cbar.set_label(zlabel) ax.set_ylabel(vary_label) ax.set_xlabel(varx_label) - fig.savefig(plotname) - - plt.close(fig) + save_show(plt, fig, plotname) def plot_hist_2D_events(plotname, valsx, valsy, nbinsx, xmin, xmax, nbinsy, ymin, ymax,