##import numpy as np
##import matplotlib.pyplot as plt
##
### Font size settings
##title_fontsize = 16
##tick_fontsize = 14
##annotation_fontsize = 14
##colorbar_tick_fontsize = 12
##
### Define the four tables
##tables = {
##    'Avg. NMI of t-SNE': (
##        np.array([
##            [68.70, 46.53, 23.37],
##            [58.85, 33.22, 26.61],
##            [62.50, 48.15, 33.45],
##            [77.04, 32.73, 30.92]
##        ]),
##        ['Image', 'Gene', 'Tabular'],
##        ['AutoDV-\nImage', 'AutoDV-\nGene', 'AutoDV-\nTabular', r't-SNE$^{*}$']
##    ),
##    'Avg. SC of t-SNE': (
##        np.array([
##            [55.15, 71.17, 58.69],
##            [67.69, 47.11, 76.11],
##            [50.89, 76.97, 48.25],
##            [63.32, 34.43, 44.42]
##        ]),
##        ['Image', 'Gene', 'Tabular'],
##        ['AutoDV-\nImage', 'AutoDV-\nGene', 'AutoDV-\nTabular', r't-SNE$^{*}$']
##    ),
##    'Avg. NMI of UMAP': (
##        np.array([
##            [73.28, 53.63, 21.94],
##            [57.81, 33.03, 32.35],
##            [55.40, 41.07, 35.15],
##            [80.45, 28.85, 24.80]
##        ]),
##        ['Image', 'Gene', 'Tabular'],
##        ['AutoDV-\nImage', 'AutoDV-\nGene', 'AutoDV-\nTabular', r'UMAP$^{*}$']
##    ),
##    'Avg. SC of UMAP': (
##        np.array([
##            [70.41, 72.59, 61.41],
##            [52.02, 47.98, 63.24],
##            [51.84, 53.80, 64.28],
##            [68.54, 47.98, 64.46]
##        ]),
##        ['Image', 'Gene', 'Tabular'],
##        ['AutoDV-\nImage', 'AutoDV-\nGene', 'AutoDV-\nTabular', r'UMAP$^{*}$']
##    )
##}
##
### Plot heatmaps with Reds colormap, annotations, and a divider line
##for title, (data, cols, rows) in tables.items():
####    data = data.T
##    fig, ax = plt.subplots(figsize=(5, 5))
##    fig.set(tight_layout=True)
##    im = ax.imshow(data, cmap='Reds')
####    cols, rows = rows, cols
##
##    # Set axis ticks and labels
##    ax.set_xticks(np.arange(len(cols)))
##    ax.set_xticklabels(cols, fontsize=tick_fontsize)
##    ax.set_yticks(np.arange(len(rows)))
##    ax.set_yticklabels(rows, fontsize=tick_fontsize)
##
##    # Rotate tick labels
##    plt.setp(ax.get_xticklabels(), rotation=45, ha="right")
##
##    # Annotate each cell with the numeric value
##    for i in range(data.shape[0]):
##        for j in range(data.shape[1]):
##            ax.text(j, i, f"{data[i, j]:.2f}", ha="center", va="center", color="black", fontsize=annotation_fontsize)
##
##    # Draw a solid horizontal line above the last row
##    ax.axhline(y=len(rows)-1 - 0.5, color='black', linewidth=2)
##
##    # Add title
##    ax.set_title(title, fontsize=title_fontsize)
##
##    # Add colorbar with adjusted tick labels
##    cbar = fig.colorbar(im, ax=ax)
##    cbar.ax.tick_params(labelsize=colorbar_tick_fontsize)
##
##    plt.tight_layout()
##    plt.show()


import matplotlib.pyplot as plt
import numpy as np

# Data for Table 1: PE type
pe_types = ['RRWP', 'LapPE-V', 'LapPE-VS', 'NMF', 'SVD', 'SignNet']
pe_nmi = 100 * np.array([0.5595, 0.5777, 0.6828, 0.7108, 0.7347, 0.0649])

# Data for Table 2: Flipping Strategy
flip_strats = ['Random', 'Sum', r'$\ell_0$', r'$\ell_1$', r'$\ell_2$', r'$\ell_{\infty}$']
flip_nmi = 100 * np.array([0.683, 0.8213, 0.8248, 0.8045, 0.6939, 0.7347])

# Data for Table 3: Loss Type
loss_types = ['KLD', 'BCE', r'L-$\mathcal{L}_{umap}$', 'G-$\mathcal{L}_{umap}$', '$\mathcal{L}_{umap}$', 'MSE']
loss_nmi = 100 * np.array([0.6626, 0.386, 0.027, 0.6737, 0.7262, 0.3858])

# Styling variables
fig_size = (5, 4)
bar_color = 'lightcyan'
edge_color = 'black'
hatch_pattern = '//'
bar_width = 0.6

# Font sizes
title_fs = 16
label_fs = 20
tick_fs = 15

def plot_bar(categories, values, title, ylim):
    plt.figure(figsize=fig_size)
    x = np.arange(len(categories))
    plt.bar(x, values, color=bar_color, edgecolor=edge_color,
            hatch=hatch_pattern, width=bar_width)
    plt.title(title, fontsize=title_fs)
    plt.ylabel('NMI (%)', fontsize=label_fs)
    plt.ylim(0, ylim)
    plt.xticks(x, categories, rotation=45, ha='right', fontsize=tick_fs)
    plt.yticks(fontsize=tick_fs)
    plt.tight_layout()
    plt.show()

# Generate charts
plot_bar(pe_types, pe_nmi, 'NMI on Different PE Types', 80)
plot_bar(flip_strats, flip_nmi, 'NMI on Different Sign Flippings', 85)
plot_bar(loss_types, loss_nmi, 'NMI on Different Loss Functions', 80)
