cite = {
    'Base': [
        [0],
        [ 8.0, 13.5, 16.0,  4.5, 15.0,  9.0,  8.5,  8.5,  5.5, 11.5],
        [0],
    ],

    'CMCA': [
        [0],
        [ 3.0,  6.0, 10.0,  2.0,  8.5,  5.0,  4.0,  3.5,  5.5,  6.0],
        [0],
    ],

    'CMCM-noAttn': [
        [129.5, 129.5, 134.5, 129.5, 135.0, 136.5, 142.0, 133.5, 130.0, 137.0],
        [ 5.0,  9.0, 12.0,  2.5, 11.0,  8.0,  7.0,  7.5,  5.0, 10.0],
        [ 9.5,  2.5,  5.0,  4.0,  9.0,  8.0,  7.0,  9.0,  8.0,  4.5],
    ],
    
    'All': [
        [124.0, 128.0, 129.0, 124.5, 129.5, 127.5, 129.0, 120.5, 128.0, 123.5],
        [ 3.0,  6.0,  9.5,  2.0,  6.0,  4.0,  5.5,  3.0,  3.0,  4.0],
        [ 5.0,  2.0,  3.0,  2.5,  4.0,  6.0,  5.0,  5.0,  5.0,  4.0],
    ],

    'Q2': [
        [218.5, 212.5, 222.5, 212.0, 213.0, 208.0, 213.5, 217.5, 216.5, 210.0],
        [ 4.0,  7.5,  9.5,  2.0,  7.0,  3.5,  5.0,  5.0,  4.0,  4.0],
        [ 5.0,  2.0,  4.0,  2.5,  4.5,  7.0,  4.0,  9.0,  4.0,  3.0],
    ],

    'Q3': [
        [232.5, 238.5, 240.0, 234.5, 235.5, 239.0, 240.0, 238.0, 233.0, 237.5],
        [ 3.0,  7.0, 10.0,  2.5,  8.5,  4.0,  4.0,  3.0,  5.0,  6.0],
        [ 6.5,  3.0,  4.0,  3.0,  5.0,  7.0,  6.0,  6.0,  6.0,  3.0],
    ],

    'Q4': [
        [202.0, 198.5, 200.5, 212.5, 197.0, 199.0, 210.5, 199.0, 207.0, 203.0],
        [ 2.5,  5.0,  8.0,  2.0,  6.0,  3.5,  4.0,  3.5,  3.0,  5.0],
        [ 4.0,  2.0,  5.0,  3.0,  3.5,  6.5,  5.0,  5.0,  5.0,  2.5],
    ],

    'Q5': [
        [224.0, 223.0, 230.5, 218.0, 222.0, 225.5, 221.0, 223.0, 226.5, 229.0],
        [ 2.5,  7.0, 10.5,  2.0,  9.0,  3.0,  5.0,  4.0,  3.0,  7.0],
        [ 5.0,  2.0,  3.5,  2.0,  3.0,  6.0,  4.0,  5.0,  4.0,  2.0],
    ],

    'Q6': [
        [203.0, 198.5, 204.0, 210.5, 199.5, 198.0, 215.5, 215.0, 218.0, 199.0],
        [ 2.0,  7.0,  8.5,  2.0,  8.0,  2.5,  3.0,  3.5,  2.5,  4.5],
        [ 5.5,  2.0,  3.0,  2.0,  3.5,  6.5,  4.0,  6.0,  4.5,  2.0],
    ],

    'Q7': [
        [203.0, 198.5, 204.0, 210.5, 199.5, 198.0, 215.5, 215.0, 218.0, 199.0],
        [ 2.0,  7.0,  8.5,  2.0,  8.0,  2.5,  3.0,  3.5,  2.5,  4.5],
        [ 5.5,  1.5,  3.0,  2.0,  4.0,  6.5,  4.0,  6.0,  4.5,  2.0],
    ],

    'Q8': [
        [223.0, 222.5, 231.0, 228.0, 231.0, 228.0, 232.0, 222.5, 231.5, 231.0],
        [ 2.5,  5.0,  9.5,  2.0,  7.0,  4.0,  5.0,  4.5,  4.0,  5.0],
        [ 5.5,  2.0,  4.5,  3.0,  4.5,  8.0,  4.5,  6.5,  7.0,  4.5],
    ],
}

clue = {
    'Base': [
        [0],
        [19.0, 21.0, 20.0, 15.0, 22.0, 19.0, 20.0, 22.0, 20.0, 20.5],
        [0],
    ],

    'CMCA': [
        [0],
        [18.0, 20.0, 18.0, 24.0, 19.0, 18.0, 17.0, 20.0, 21.0, 18.0],
        [0],
    ],

    'CMCM-noAttn': [
        [113.0, 123.0, 124.0, 126.0, 130.0, 116.0, 120.0, 129.0, 125.5, 128.0],
        [21.0, 21.5, 21.0, 18.0, 22.5, 19.0, 21.0, 17.0, 16.0, 18.0],
        [25.0, 16.0, 23.0, 18.0, 21.0, 18.0, 23.5, 20.0, 20.5, 20.5],
    ],

    'All': [
        [126.0, 119.0, 127.5, 125.0, 130.0, 122.5, 121.0, 116.0, 126.0, 126.0],
        [20.5, 23.0, 20.5, 17.0, 16.0, 22.5, 18.0, 17.5, 19.0, 16.5],
        [20.0, 19.0, 17.0, 20.0, 17.0, 20.5, 21.0, 18.0, 17.0, 17.0],
    ],

    'Visible': [
        [189.0, 181.0, 186.0, 200.0, 183.5, 187.5, 191.0, 179.0, 187.0, 180.5],
        [21.0, 23.0, 21.0, 21.0, 16.5, 24.0, 19.0, 20.0, 19.0, 16.5],
        [21.5, 21.0, 19.0, 21.0, 17.0, 25.0, 23.0, 18.0, 16.5, 14.0],
    ],
    
    'Subjective': [
        [239.5, 231.0, 241.0, 226.5, 236.5, 239.0, 228.0, 240.0, 240.5, 239.5],
        [22.0, 27.0, 26.0, 24.0, 24.5, 28.0, 26.5, 20.0, 27.5, 21.5],
        [29.5, 24.0, 22.0, 22.0, 25.0, 29.5, 27.0, 27.5, 20.0, 23.0],
    ],

    'Action': [
        [178.5, 171.5, 169.0, 183.5, 182.0, 187.0, 180.0, 173.0, 182.5, 178.0],
        [22.0, 17.5, 21.0, 20.5, 19.0, 27.0, 22.5, 21.0, 19.0, 22.0],
        [19.0, 20.5, 20.5, 21.0, 22.0, 20.5, 16.0, 24.0, 22.0, 23.0],
    ],

    'Story': [
        [207.0, 213.5, 198.0, 202.0, 220.0, 196.0, 208.5, 207.0, 198.5, 201.5],
        [16.0, 22.0, 18.0, 18.0, 19.0, 20.0, 21.0, 18.0, 15.5, 17.0],
        [18.0, 16.0, 20.5, 16.5, 16.0, 18.0, 21.0, 16.5, 17.0, 17.5],
    ],

    'Meta': [
        [166.5, 166.5, 175.0, 165.5, 171.0, 168.0, 164.5, 175.5, 173.5, 174.0],
        [18.0, 22.0, 20.5, 16.5, 18.0, 22.0, 19.0, 19.5, 20.0, 18.5],
        [19.0, 17.0, 21.0, 18.0, 20.0, 20.0, 22.0, 19.0, 17.5, 18.0],
    ],

    'Irrelevant': [
        [215.0, 227.0, 218.5, 226.0, 229.5, 223.0, 222.0, 223.0, 221.0, 221.0],
        [16.0, 19.5, 20.0, 17.0, 19.0, 21.0, 19.0, 19.0, 18.5, 18.0],
        [23.0, 18.5, 21.0, 20.0, 19.0, 21.0, 21.5, 21.0, 22.0, 16.0],
    ],
}

from matplotlib import pyplot as plt
import numpy as np

labels = ['CI', 'sim', 'sim*conf']

cite_model_names = ['Base', 'CMCA', 'CMCM-noAttn', 'All', 'Q2', 'Q3', 'Q4', 'Q5', 'Q6', 'Q7', 'Q8']
clue_model_names = ['Base', 'CMCA', 'CMCM-noAttn', 'All', 'Visible', 'Subjective', 'Action', 'Story', 'Meta', 'Irrelevant']

model_names = cite_model_names
data= cite
fig_name = 'CITE++.jpg'

# model_names = clue_model_names
# data= clue
# fig_name = 'Clue.jpg'

plt.figure(figsize=(20,16))

dim = len(labels)
w = 0.75
dimw = w / dim
x = np.arange(len(model_names))
for i, label in enumerate(labels):
    if i == 0:
        continue

    y = [data[model][i] for model in model_names]
    y_mean = [np.mean(yi) for yi in y]
    if label == 'sim':
        plt.hlines(y_mean[1], x[0]-w, x[-1]+w, linestyles='dashed')
    y_std = [np.std(yi) for yi in y]
    b = plt.bar(x + i * dimw, y_mean, dimw, bottom=0.001, label=label)
    # b = plt.bar(x + i * dimw, y_mean, dimw, bottom=0.001, yerr=y_std, label=label)

plt.xticks(x + w/2, model_names, fontsize=20)
plt.yticks(fontsize=30)
# plt.xticklabels(model_names)
# plt.yscale('log')

# plt.ylim(1, 300)
plt.ylabel('MedR', fontsize=40)
plt.title(fig_name.split('.')[0], fontsize=40)

plt.legend(fontsize=40)
plt.tight_layout()

plt.savefig(fig_name)