def create_negros_panay_plots(
        config_path,
        ordered_info_path,
        unordered_info_path,
        out_dir):
    if not os.path.exists(out_dir):
        os.mkdir(out_dir)
    dpp_num_div_values, dpp_div_model_values, dpp_ordered_model_values = get_dpp_prior_values(
                    config_path = config_path,
                    num_samples = 1000000)
    ordered_hists = get_histograms(config_path = config_path,
            info_path = ordered_info_path,
            num_div_values = dpp_num_div_values,
            div_model_values = dpp_div_model_values,
            ordered_div_model_values = dpp_ordered_model_values,
            iteration_index = 249,
            y_limits = [0.25, 0.25, 0.15, 0.15],
            xtick_label_size = 11.0)
    unordered_hists = get_histograms(config_path = config_path,
            info_path = unordered_info_path,
            num_div_values = dpp_num_div_values,
            div_model_values = dpp_div_model_values,
            ordered_div_model_values = dpp_ordered_model_values,
            iteration_index = 249,
            y_limits = [0.25, 0.25, 0.15, 0.15],
            xtick_label_size = 11.0)

    hists = [unordered_hists[0]] + ordered_hists

    row_labels = [r'Posterior $\mathbb{M}_{DPP}$', r'Posterior $\mathbb{M}^{\circ}_{DPP}$', 'Prior', r'Prior $\mathbb{E}(p(\mathbf{t}))$', r'Prior $\mathbb{E}(p(\mathbf{t^{\circ}}))$']

    pg = PlotGrid(subplots = hists,
            num_columns = 1,
            share_x = True,
            share_y = False,
            height = 7.2,
            width = 2.5,
            auto_height = False,
            title = r'Number of divergences, $|\tau|$',
            title_top = False,
            title_size = 10.0,
            y_title = 'Probability',
            row_labels = row_labels,
            row_label_offset = 0.08,
            row_label_size = 12.0)
    pg.auto_adjust_margins = False
    pg.margin_top = 0.98
    pg.margin_bottom = 0.03
    pg.margin_right = 0.88
    pg.margin_left = 0.05
    pg.padding_between_vertical = 1.0
    pg.reset_figure()
    pg.set_shared_x_limits()
    pg.set_shared_y_limits(by_row = True)
    pg.reset_figure()
    pg.savefig(os.path.join(out_dir, 'negros-panay-psi.pdf'))
def create_plots(dpp_info_path, old_info_path, out_dir):
    # matplotlib.rc('text',**{'usetex': True})
    # old = ([1] * 992) + ([2] * 8)
    if not os.path.exists(out_dir):
        os.mkdir(out_dir)
    dmc_sim = DMCSimulationResults(dpp_info_path)
    dmc_sim_old = DMCSimulationResults(old_info_path)
    psi_path = dmc_sim.get_result_path_prefix(1, 1, 1) + '99-psi-results.txt'
    psi_path_old = dmc_sim_old.get_result_path_prefix(1, 1, 1) + '99-psi-results.txt'
    psis = []
    for d in spreadsheet_iter([psi_path]):
        n = int(round(10000 * float(d['estimated_prob'])))
        psis.extend([int(d['num_of_div_events'])] * n)
    psis_old = []
    for d in spreadsheet_iter([psi_path_old]):
        n = int(round(10000 * float(d['estimated_prob'])))
        psis_old.extend([int(d['num_of_div_events'])] * n)
    bins = range(1, dmc_sim.num_taxon_pairs + 2)
    hd = HistData(x = psis,
            normed = True,
            bins = bins,
            histtype = 'bar',
            align = 'mid',
            orientation = 'vertical',
            zorder = 0)
    # hd_old= HistData(x = old,
    hd_old= HistData(x = psis_old,
            normed = True,
            bins = bins,
            histtype = 'bar',
            align = 'mid',
            orientation = 'vertical',
            zorder = 0)
    tick_labels = []
    for x in bins[0:-1]:
        if x % 2:
            tick_labels.append(str(x))
        else:
            tick_labels.append('')
    xticks_obj = Ticks(ticks = bins,
            labels = tick_labels,
            horizontalalignment = 'left')
    hist = ScatterPlot(hist_data_list = [hd],
            x_label = 'Number of divergence events',
            y_label = 'Posterior probability',
            xticks_obj = xticks_obj)
    hist_old = ScatterPlot(hist_data_list = [hd_old],
            x_label = 'Number of divergence events',
            y_label = 'Posterior probability',
            xticks_obj = xticks_obj)
    hist.set_xlim(left = bins[0], right = bins[-1])
    hist_old.set_xlim(left = bins[0], right = bins[-1])
    hist.set_ylim(bottom = 0.0, top = 0.1)
    pg = PlotGrid(subplots = [hist],
            num_columns = 1,
            height = 4.0,
            width = 6.5,
            label_schema = None,
            auto_height = False)
    pg.auto_adjust_margins = False
    pg.margin_top = 1
    pg.reset_figure()
    pg.savefig(os.path.join(out_dir, 'philippines-dpp-psi-posterior.pdf'))

    # hist.set_ylim(bottom = 0.0, top = 1.0)
    hist.set_ylim(bottom = 0.0, top = 0.5)
    hist.set_ylabel('')
    # hist_old.set_ylim(bottom = 0.0, top = 1.0)
    hist_old.set_ylim(bottom = 0.0, top = 0.5)
    pg = PlotGrid(subplots = [hist_old, hist],
            num_columns = 2,
            height = 3.5,
            width = 8.0,
            share_x = True,
            share_y = True,
            label_schema = None,
            auto_height = False,
            # column_labels = [r'\texttt{msBayes}', r'\texttt{dpp-msbayes}'],
            column_labels = [r'msBayes', r'dpp-msbayes'],
            column_label_size = 18.0)
    pg.auto_adjust_margins = False
    pg.margin_top = 0.92
    pg.padding_between_horizontal = 1.0
    pg.reset_figure()
    pg.savefig(os.path.join(out_dir, 'philippines-dpp-psi-posterior-old-vs-dpp.pdf'))
    pg.label_schema = 'uppercase'
    pg.reset_figure()
    pg.savefig(os.path.join(out_dir, 'philippines-dpp-psi-posterior-old-vs-dpp-labels.pdf'))

    prior_psis = get_dpp_psi_values(dmc_sim.num_taxon_pairs, 1.5, 18.099702, num_sims = 100000)
    prior_hd = HistData(x = prior_psis,
            normed = True,
            bins = bins,
            histtype = 'bar',
            align = 'mid',
            orientation = 'vertical',
            zorder = 0)
    prior_hist = ScatterPlot(hist_data_list = [prior_hd],
            x_label = 'Number of divergence events',
            y_label = 'Probability',
            xticks_obj = xticks_obj)
    prior_hist.set_xlim(left = bins[0], right = bins[-1])
    prior_hist.set_ylim(bottom = 0.0, top = 0.12)
    hist.set_ylim(bottom = 0.0, top = 0.12)
    pg = PlotGrid(subplots = [prior_hist, hist],
            num_columns = 2,
            height = 3.5,
            width = 8.0,
            share_x = True,
            share_y = True,
            label_schema = None,
            auto_height = False,
            # column_labels = [r'\texttt{msBayes}', r'\texttt{dpp-msbayes}'],
            column_labels = [r'Prior', r'Posterior'],
            column_label_size = 18.0)
    pg.auto_adjust_margins = False
    pg.margin_top = 0.92
    pg.padding_between_horizontal = 1.0
    pg.reset_figure()
    pg.savefig(os.path.join(out_dir, 'philippines-dpp-psi-posterior-prior.pdf'))
    pg.label_schema = 'uppercase'
    pg.reset_figure()
    pg.savefig(os.path.join(out_dir, 'philippines-dpp-psi-posterior-prior-lablels.pdf'))

    prior_psis_old = []
    for i in range(22):
        prior_psis_old.extend([i + 1] * 100)
    prior_hd_old = HistData(x = prior_psis_old,
            normed = True,
            bins = bins,
            histtype = 'bar',
            align = 'mid',
            orientation = 'vertical',
            zorder = 0)
    prior_hist_old = ScatterPlot(hist_data_list = [prior_hd_old],
            x_label = 'Number of divergence events',
            y_label = 'Prior probability',
            xticks_obj = xticks_obj)
    prior_hist.set_xlim(left = bins[0], right = bins[-1])
    prior_hist.set_ylim(bottom = 0.0, top = 0.5)

    hist.set_ylim(bottom = 0.0, top = 0.5)
    prior_hist.set_ylim(bottom = 0.0, top = 0.5)

    for h in [hist_old, hist, prior_hist_old, prior_hist]:
        h.set_ylabel(ylabel = '')
        h.set_xlabel(xlabel = '')
        h.set_title_text('')
        h.set_extra_y_label('')

    pg = PlotGrid(subplots = [hist_old, hist, prior_hist_old, prior_hist],
            num_columns = 2,
            height = 6.0,
            width = 8.0,
            share_x = True,
            share_y = False,
            label_schema = None,
            auto_height = False,
            title = r'Number of divergence events',
            title_top = False,
            title_size = 16.0,
            y_title = 'Probability',
            y_title_size = 16.0,
            column_labels = [r'msBayes', r'dpp-msbayes'],
            row_labels = ['Posterior', 'Prior'],
            column_label_offset = 0.07,
            column_label_size = 22.0,
            row_label_offset = 0.04,
            row_label_size = 20.0)
    pg.auto_adjust_margins = False
    pg.margin_top = 0.94
    pg.margin_bottom = 0.045
    pg.margin_right = 0.95
    pg.margin_left = 0.045
    pg.padding_between_vertical = 0.5
    pg.padding_between_horizontal = 1.0
    pg.reset_figure()
    pg.set_shared_x_limits()
    pg.set_shared_y_limits(by_row = True)
    pg.reset_figure()
    pg.savefig(os.path.join(out_dir, 'philippines-dpp-psi-posterior-old-vs-dpp-with-prior.pdf'))
def create_plots(
        dpp_config_path,
        uniform_config_path,
        old_config_path,
        dpp_info_path,
        dpp_simple_info_path,
        dpp_inform_info_path,
        uniform_info_path,
        old_info_path,
        out_dir):
    # matplotlib.rc('text',**{'usetex': True})
    if not os.path.exists(out_dir):
        os.mkdir(out_dir)
    dpp_num_div_values, dpp_div_model_values, dpp_ordered_model_values = get_dpp_prior_values(
                    config_path = dpp_config_path,
                    num_samples = 1000000)
    dpp_hists = get_histograms(config_path = dpp_config_path,
            info_path = dpp_info_path,
            num_div_values = dpp_num_div_values,
            div_model_values = dpp_div_model_values,
            ordered_div_model_values = dpp_ordered_model_values)
    dpp_simple_hists = get_histograms(config_path = dpp_config_path,
            info_path = dpp_simple_info_path,
            num_div_values = dpp_num_div_values,
            div_model_values = dpp_div_model_values,
            ordered_div_model_values = dpp_ordered_model_values)
    dpp_inform_hists = get_histograms(config_path = dpp_config_path,
            info_path = dpp_inform_info_path,
            num_div_values = dpp_num_div_values,
            div_model_values = dpp_div_model_values,
            ordered_div_model_values = dpp_ordered_model_values)
    uniform_hists = get_histograms(config_path = uniform_config_path,
            info_path = uniform_info_path,
            num_samples = 100000)
    old_hists = get_histograms(config_path = old_config_path,
            info_path = old_info_path,
            num_samples = 100000)

    hists = []
    for i in range(len(dpp_hists)):
        hists.append(old_hists[i])
        hists.append(uniform_hists[i])
        hists.append(dpp_hists[i])
        hists.append(dpp_inform_hists[i])
        hists.append(dpp_simple_hists[i])

    column_labels = [r'$\mathbf{M}_{msBayes}$', r'$\mathbf{M}_{Uniform}$', r'$\mathbf{M}_{DPP_{ }}$', r'$\mathbf{M}^{inform}_{DPP}$', r'$\mathbf{M}^{simple}_{DPP}$']
    row_labels = ['Posterior', 'Prior', r'Prior $\mathbb{E}(p(\mathbf{t}))$', r'Prior $\mathbb{E}(p(\mathbf{t^{\circ}}))$']

    pg = PlotGrid(subplots = hists,
            num_columns = 5,
            share_x = True,
            share_y = False,
            height = 7.2,
            width = 11.0,
            auto_height = False,
            title = r'Number of divergence events, $|\tau|$',
            title_top = False,
            y_title = 'Probability',
            column_labels = column_labels,
            column_label_offset = 0.17,
            row_labels = row_labels,
            row_label_offset = 0.08)
    pg.auto_adjust_margins = False
    pg.margin_top = 0.93
    pg.margin_bottom = 0.04
    pg.margin_right = 0.965
    pg.padding_between_vertical = 1.0
    pg.reset_figure()
    pg.set_shared_x_limits()
    pg.set_shared_y_limits(by_row = True)
    pg.reset_figure()
    pg.savefig(os.path.join(out_dir, 'philippines-psi.pdf'))