123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- import glob
- import os
- import pandas as pd
- import matplotlib.pyplot as plt
- import time
- import numpy as np
- import seaborn as sns
- 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,alpha=a)
- 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"],alpha=a)
- 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 = sns.color_palette()
- a = 0.6
- for scale in scales:
- draw(scale)
- drawTogether()
|