def make_figures(guesses, crystal_family, froot):
    if crystal_family:
        lower_gen = SpGr.edges['genus'][crystal_family][0]
        upper_gen = SpGr.edges['genus'][crystal_family][1]
    else:
        lower_gen = SpGr.edges['genus'][FAMILIES[0]][0]
        upper_gen = SpGr.edges['genus'][FAMILIES[(- 1)]][1]
    fam_range = range(SpGr.edges['species'][lower_gen][0], (1 + SpGr.edges['species'][upper_gen][1]))
    fig_ang = 300
    phi = ((((2 * np.pi) * fig_ang) / 360) / ((max(fam_range) - min(fam_range)) + 1))
    thet = (fig_ang / ((max(fam_range) - min(fam_range)) + 1))
    fam_axes = [1, 3, 16, 75, 143, 168, 195]
    fig1 = plt.figure(2, figsize=(16, 8))
    plt.clf()
    ax1 = fig1.add_axes([0.03, 0.1, 0.96, 0.8])
    fam_color = ['k', 'g', 'b', 'c', 'm', 'y', 'k']
    for k in range((len(fam_axes) - 1)):
        ax1.axvspan((fam_axes[k] - 0.5), (fam_axes[(k + 1)] - 0.5), facecolor=fam_color[k], alpha=0.5)
    ax1.axvspan((fam_axes[(- 1)] - 0.5), (np.max(fam_range) - 0.5), alpha=0.3)
    plt.ion
    fig2 = plt.figure(3, figsize=(8, 8))
    plt.clf()
    plt.ion
    ax2 = fig2.add_axes([0.1, 0.1, 0.8, 0.8], polar=True)
    ax2.set_thetamin(1)
    ax2.set_rmin(0)
    ax2.set_thetamax(fig_ang)
    ax2.set_rlabel_position(30)
    ax2.set_theta_direction((- 1))
    ax2.set_theta_zero_location('S', offset=((- (360 - fig_ang)) / 2))
    prev_histograms_1 = []
    prev_histograms_2 = []
    plots_1 = []
    plots_2 = []
    num_pred = np.prod(prediction_per_level)
    for rank in range(1, (num_pred + 1)):
        histo = np.histogram([g for g in guesses['species_{}'.format(rank)]], weights=[g for g in guesses['spec_confidence_{}'.format(rank)]], bins=np.arange((min(fam_range) - 0.5), (max(fam_range) + 1.5)))
        histo_log = np.array([((np.log10(float(h)) + 1) if (h > 0) else 0) for h in histo[0]])
        if (rank > 1):
            plt.figure(2)
            plot_1 = plt.bar(fam_range, histo[0], bottom=np.sum(np.vstack(prev_histograms_1), axis=0), align='center', width=1.1)
            plt.figure(3)
            sum_hist = np.sum(np.vstack(prev_histograms_1), axis=0)
            log_sum = np.array([((np.log10(float(h)) - 1) if (h > 0) else (- 1)) for h in sum_hist])
            plot_2 = plt.bar([(f * phi) for f in fam_range], histo_log, bottom=log_sum, align='center', width=phi)
        else:
            plt.figure(2)
            plot_1 = plt.bar(fam_range, histo[0], align='center', color='red', width=1.1)
            plt.figure(3)
            plot_2 = plt.bar([(f * phi) for f in fam_range], histo_log, bottom=(- 1), align='center', color='red', width=phi)
        plots_1.append(plot_1)
        plots_2.append(plot_2)
        plt.figure(2)
        plt.yticks(rotation='vertical')
        plt.xticks(fam_range, rotation='vertical')
        prev_histograms_1.append(histo[0])
        prev_histograms_2.append(histo[0])
    plt.figure(2)
    r_max = 0
    for rect in plot_1:
        n_max = (rect.get_height() + rect.get_y())
        if (n_max > r_max):
            r_max = n_max
    for k in range((len(FAMILIES) - 1)):
        if (k == 0):
            ym_t = (r_max * 0.7)
            cent = 'left'
        else:
            ym_t = (r_max * 0.6)
            cent = 'center'
        ax1.text(((fam_axes[(k + 1)] + fam_axes[k]) / 2), ym_t, FAMILIES[k], horizontalalignment=cent)
    ax1.text(((fam_axes[(- 1)] + np.max(fam_range)) / 2), ym_t, FAMILIES[(- 1)], horizontalalignment='center')
    ax1.autoscale(enable=True, axis='x', tight=True)
    ax1.tick_params(axis='x', which='major', labelsize=6)
    plt.xlabel('Prediction', fontsize=10)
    plt.ylabel('Counts', fontsize=10)
    leg_list = ['species_{}'.format((k + 1)) for k in range(num_pred)]
    plt.legend(plots_1, leg_list)
    print((('Results/' + froot) + '_gen2.png'))
    plt.savefig((('Results/' + froot) + '_gen2.png'), dpi=300)
    plt.figure(3)
    r_ticks = list(range(int(np.floor(ax2.get_rmin())), int((np.ceil(ax2.get_rmax()) + 1))))
    ax2.set_rgrids(r_ticks, labels=[('10e' + str(r)) for r in r_ticks])
    ax2.set_thetagrids([(f * thet) for f in fam_axes], labels=FAMILIES)
    plt.legend(plots_2, leg_list)
def make_figures(guesses, crystal_family, froot):
    if crystal_family:
        lower_gen = SpGr.edges['genus'][crystal_family][0]
        upper_gen = SpGr.edges['genus'][crystal_family][1]
    else:
        lower_gen = SpGr.edges['genus'][FAMILIES[0]][0]
        upper_gen = SpGr.edges['genus'][FAMILIES[(- 1)]][1]
    fam_range = range(SpGr.edges['species'][lower_gen][0], (1 + SpGr.edges['species'][upper_gen][1]))
    fig_ang = 300
    phi = ((((2 * np.pi) * fig_ang) / 360) / ((max(fam_range) - min(fam_range)) + 1))
    thet = (fig_ang / ((max(fam_range) - min(fam_range)) + 1))
    fam_axes = [1, 3, 16, 75, 143, 168, 195]
    fig1 = plt.figure(2, figsize=(16, 8))
    plt.clf()
    ax1 = fig1.add_axes([0.03, 0.1, 0.96, 0.8])
    fam_color = ['k', 'g', 'b', 'c', 'm', 'y', 'k']
    for k in range((len(fam_axes) - 1)):
        ax1.axvspan((fam_axes[k] - 0.5), (fam_axes[(k + 1)] - 0.5), facecolor=fam_color[k], alpha=0.5)
    ax1.axvspan((fam_axes[(- 1)] - 0.5), (np.max(fam_range) - 0.5), alpha=0.3)
    plt.ion
    fig2 = plt.figure(3, figsize=(8, 8))
    plt.clf()
    plt.ion
    ax2 = fig2.add_axes([0.1, 0.1, 0.8, 0.8], polar=True)
    ax2.set_thetamin(1)
    ax2.set_rmin(0)
    ax2.set_thetamax(fig_ang)
    ax2.set_rlabel_position(30)
    ax2.set_theta_direction((- 1))
    ax2.set_theta_zero_location('S', offset=((- (360 - fig_ang)) / 2))
    prev_histograms_1 = []
    prev_histograms_2 = []
    plots_1 = []
    plots_2 = []
    num_pred = np.prod(prediction_per_level)
    for rank in range(1, (num_pred + 1)):
        histo = np.histogram([g for g in guesses['species_{}'.format(rank)]], weights=[g for g in guesses['spec_confidence_{}'.format(rank)]], bins=np.arange((min(fam_range) - 0.5), (max(fam_range) + 1.5)))
        histo_log = np.array([((np.log10(float(h)) + 1) if (h > 0) else 0) for h in histo[0]])
        if (rank > 1):
            plt.figure(2)
            plot_1 = plt.bar(fam_range, histo[0], bottom=np.sum(np.vstack(prev_histograms_1), axis=0), align='center', width=1.1)
            plt.figure(3)
            sum_hist = np.sum(np.vstack(prev_histograms_1), axis=0)
            log_sum = np.array([((np.log10(float(h)) - 1) if (h > 0) else (- 1)) for h in sum_hist])
            plot_2 = plt.bar([(f * phi) for f in fam_range], histo_log, bottom=log_sum, align='center', width=phi)
        else:
            plt.figure(2)
            plot_1 = plt.bar(fam_range, histo[0], align='center', color='red', width=1.1)
            plt.figure(3)
            plot_2 = plt.bar([(f * phi) for f in fam_range], histo_log, bottom=(- 1), align='center', color='red', width=phi)
        plots_1.append(plot_1)
        plots_2.append(plot_2)
        plt.figure(2)
        plt.yticks(rotation='vertical')
        plt.xticks(fam_range, rotation='vertical')
        prev_histograms_1.append(histo[0])
        prev_histograms_2.append(histo[0])
    plt.figure(2)
    r_max = 0
    for rect in plot_1:
        n_max = (rect.get_height() + rect.get_y())
        if (n_max > r_max):
            r_max = n_max
    for k in range((len(FAMILIES) - 1)):
        if (k == 0):
            ym_t = (r_max * 0.7)
            cent = 'left'
        else:
            ym_t = (r_max * 0.6)
            cent = 'center'
        ax1.text(((fam_axes[(k + 1)] + fam_axes[k]) / 2), ym_t, FAMILIES[k], horizontalalignment=cent)
    ax1.text(((fam_axes[(- 1)] + np.max(fam_range)) / 2), ym_t, FAMILIES[(- 1)], horizontalalignment='center')
    ax1.autoscale(enable=True, axis='x', tight=True)
    ax1.tick_params(axis='x', which='major', labelsize=6)
    plt.xlabel('Prediction', fontsize=10)
    plt.ylabel('Counts', fontsize=10)
    leg_list = ['species_{}'.format((k + 1)) for k in range(num_pred)]
    plt.legend(plots_1, leg_list)
    print((('Results/' + froot) + '_gen2.png'))
    plt.savefig((('Results/' + froot) + '_gen2.png'), dpi=300)
    plt.figure(3)
    r_ticks = list(range(int(np.floor(ax2.get_rmin())), int((np.ceil(ax2.get_rmax()) + 1))))
    ax2.set_rgrids(r_ticks, labels=[('10e' + str(r)) for r in r_ticks])
    ax2.set_thetagrids([(f * thet) for f in fam_axes], labels=FAMILIES)
    plt.legend(plots_2, leg_list)