# %% import pandas as pd import numpy as np from scipy import stats df = pd.read_csv('UCL 24 - freebreaks_BaseScenario_violations.csv') # %% df.head() # %% for column in df: print(column) print("\t",df[column][0]) try: print("\t",df[column][1:]) print("\t",round(df[column][1:].astype('float64').mean(),2)) except: pass # %% import matplotlib.pyplot as plt # width of the bars barWidth = 15 # Choose the height of the blue bars ucl = [ ] # Choose the height of the cyan bars relaxed = [ 0, round(0,2), round(0.458333333333333,2), round(2.83333333333333,2), 0, round(0.25,2), round(5.83333333333333,2), round(0,2), 0, round(2.70833333333333,2), round(0,2), round(9.625,2), ] diff = [-round(ucl[i] - relaxed[i],2) for i in range(len(ucl))] bars4 = ucl + relaxed + diff # The x position of bars # r1 = np.arange(len(ucl)) # r2 = [x + barWidth for x in r1] # r3 = [x + 2*barWidth for x in r1] r1 = [4*i*barWidth for i in range(12)] r2 = [4*i*barWidth+1*barWidth for i in range(12)] r3 = [4*i*barWidth+2*barWidth for i in range(12)] r4 = r1 + r2 + r3 # Create labels label = bars4 # Text on the top of each bar for i in range(len(r4)): plt.text(x = r4[i]-0.3 , y = bars4[i]+0.1, s = label[i], size = 6) # Create blue bars plt.bar(r1, ucl, width = barWidth, color = 'blue', edgecolor = 'black', capsize=7, label='classic') # Create cyan bars plt.bar(r2, relaxed, width = barWidth, color = 'cyan', edgecolor = 'black', capsize=7, label='relaxed') # Create cyan bars plt.bar(r3, diff, width = barWidth, color = 'red', edgecolor = 'black', capsize=7, label='diff') # general layout plt.xticks([10+ r*4*barWidth for r in range(len(ucl))], ['Pair Hard','Pair A','Pair B','Pair C','HA Hard','HA A','HA B','HA C','Enc Hard','Enc A','Enc B','Enc C']) plt.ylabel('# Violations') plt.legend() # plt.ylim((0,3)) plt.title("Evaluation") # Show graphic plt.show() # %%