parser = argparse.ArgumentParser() parser.add_argument('datapath', type=str) ns = parser.parse_args() with open(ns.datapath) as f: (plot_data, xs_ever_probed) = pickle.load(f) sns.set(font_scale=3) fig = plt.figure() fig.set_dpi(30) fig.set_figwidth(30) fig.set_figheight(10) gs = gridspec.GridSpec(1, 2, width_ratios=[2,1]) plot_ax = fig.add_subplot(gs[0]) legend_ax = fig.add_subplot(gs[1]) decorations = [] decorations.append(plotutils.centered_rectangle( create_bayesopt_quad_plots.plotdata_optimum(plot_data), **plotparams.QUAD_OPTIMUM)) decorations.append(Ellipse( create_bayesopt_quad_plots.next_probe(plot_data), **plotparams.QUAD_XNEXT)) create_bayesopt_quad_plots.draw_plot(plot_data, list(xs_ever_probed), plot_ax, decorations) create_bayesopt_quad_plots.make_legend(legend_ax) outfname = 'bayesopt_output/typical_quad.png' print "Saving figure %s" % (outfname,) fig.savefig(outfname, dpi=fig.dpi,bbox_inches='tight')
fig.set_figwidth(3*plotparams.GP_PLOT_WIDTH) # Assign each key of shown_plot_datas to a subplot axdict = {i: fig.add_subplot(gs0[ii]) for (ii,i) in enumerate(sorted(shown_plot_datas))} ## Make one subplot for each plot_data plot_keys = list(sorted(all_plot_datas)) for i in plot_keys: plot_data = all_plot_datas[i] print "Plotting stage %s:" % (i,) print "sigma=%f, l=%f" % (plot_data.sigma, plot_data.l) print "Xseen = ", plot_data.Xseen print "Yseen = ", plot_data.Yseen if i == 0: decorations = [] else: decorations = [plotutils.centered_rectangle(plotdata_optimum(plot_data), **plotparams.GP_OPTIMUM)] if i in next_probe_dict: next_probe = next_probe_dict[i] decorations.append(Ellipse(next_probe, **plotparams.GP_XNEXT)) # Here I do redundant plotting because I do not want to put in the # effort to get plot sizes of the pngs right. # This code is needlessly complicated. substrates = [] if ns.verbose_plotting: cur_fig, cur_ax = plt.subplots() cur_fig.set_figheight(plotparams.GP_PLOT_HEIGHT) cur_fig.set_figwidth(plotparams.GP_PLOT_WIDTH) def callback(): plotutils.save_just_subplot(cur_fig, cur_ax, j('{}.png'.format(i))) plt.close(cur_fig)
gs = gridspec.GridSpec(1, 2, width_ratios=[1,2]) gs0 = gridspec.GridSpecFromSubplotSpec(num_shown_plots, 1, subplot_spec=gs[0]) gs1 = gridspec.GridSpecFromSubplotSpec(2, 2, subplot_spec=gs[1], width_ratios=[1,300]) fig = plt.figure() fig.set_dpi(30) fig.set_figheight(num_shown_plots * plotparams.QUAD_PLOT_HEIGHT) fig.set_figwidth(3*plotparams.QUAD_PLOT_WIDTH) # Assign each key of shown_plot_datas to a subplot axdict = {i: fig.add_subplot(gs0[ii]) for (ii,i) in enumerate(sorted(shown_plot_datas))} xs_ever_probed = set() for i, plot_data in all_plot_datas.items(): print "Working on plot number {}".format(i) decorations = [] decorations.append(plotutils.centered_rectangle(plotdata_optimum(plot_data), **plotparams.QUAD_OPTIMUM)) decorations.append(Ellipse(next_probe(plot_data), **plotparams.QUAD_XNEXT)) xs_ever_probed.update(plot_data.active_data_xs) # Here I do redundant plotting because I do not want to put in the # effort to get plot sizes of the pngs right. # This code is needlessly complicated. substrates = [] if ns.verbose_plotting: cur_fig, cur_ax = plt.subplots() cur_fig.set_figheight(plotparams.QUAD_PLOT_HEIGHT) cur_fig.set_figwidth(plotparams.QUAD_PLOT_WIDTH) def callback(): plotutils.save_just_subplot(cur_fig, cur_ax, j('{}.png'.format(i)))