import glob import os from numpy.lib.function_base import append import pandas as pd import matplotlib.pyplot as plt import time import numpy as np path = os.getcwd() def draw(filename): conditions = file['condition'] result = file[filename] plt.figure(figsize=(9, 6), dpi=100) plt.bar(conditions, result, width=0.35, color=colors) plt.title(filename) plt.ylabel('score') plt.grid(alpha=0, linestyle=':') plt.savefig(filename + ".jpg", dpi=300) #plt.show() def drawTogether(): plt.figure(figsize=(15,7)) x = np.arange(len(scales)) total_width, n = 0.8, 4 width = total_width / n for i in range(0,4): result = [] for scale in scales: result.append(file.iloc[i][scale]) plt.bar(x+width*(i-1),result,width=width,color=colors[i],label=file.iloc[i]["condition"]) plt.legend() plt.xticks(x+width/2,scales) #plt.show() plt.savefig("summary.jpg",dpi=300) # Merge all the .csv file start with "HectorVR", and all_files = glob.glob(os.path.join(path, "HectorVR*.csv")) df_from_each_file = (pd.read_csv(f, sep=',') for f in all_files) df_merged = pd.concat(df_from_each_file, ignore_index=True) # Save the file to Merged.csv in the same folder df_merged.to_csv( "Merged.csv") # save the results in csv file = df_merged.groupby(["condition"]).mean() file.to_csv( "Mean.csv") file = pd.read_csv("Mean.csv") scales = ["mental-demand","physical-demand","temporal-demand","performance", "effort","frustration","total"] colors = ['lightcoral', 'gold','plum', 'paleturquoise'] for scale in scales: draw(scale) drawTogether()