statistic.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import glob
  2. import os
  3. from numpy.lib.function_base import append
  4. import pandas as pd
  5. import matplotlib.pyplot as plt
  6. import time
  7. import seaborn as sns
  8. import numpy as np
  9. import csv
  10. import joypy
  11. def draw(filename,start):
  12. file = pd.read_csv(FileName,usecols=[start,start+3,start+6,start+9])
  13. temp = file.values.tolist()
  14. file = np.transpose(temp)
  15. kwargs = {
  16. "bins": 20,
  17. "histtype": "stepfilled",
  18. "alpha": 0.5
  19. }
  20. fig,ax = plt.subplots(figsize=(10, 7))
  21. for i in range(0,4):
  22. ax.hist(file[i], color = colors[i],label=conditions[i], **kwargs)
  23. ax.set_title(filename)
  24. ax.legend()
  25. plt.show()
  26. def draw2(filename,start):
  27. file = pd.read_csv(FileName,usecols=[start,start+3,start+6,start+9])
  28. temp = file.values.tolist()
  29. # Draw Stripplot
  30. plt.figure(figsize=(10,5))
  31. medianprops = dict(linestyle='-', linewidth=1, color='black')
  32. f = plt.boxplot(file,patch_artist = True,medianprops=medianprops,labels=conditions)
  33. for box,c in zip(f['boxes'], colors):
  34. box.set(color='black', linewidth=1)
  35. box.set_alpha(a)
  36. box.set( facecolor = c )
  37. plt.title(filename, fontsize=15)
  38. plt.ylim(0.5,5.5)
  39. plt.savefig(filename+".jpg",dpi=300)
  40. #plt.show()
  41. FileName = "Hector V2 Nutzerstudie.csv"
  42. file = pd.read_csv(FileName)
  43. colors = sns.color_palette()
  44. a = 0.6
  45. conditions = ["Handle","Lab","Remote","UI"]
  46. questions = ["I found it easy to move robot in desired position","I found it easy to concentrate on controlling the robot","I found it easy to perceive the details of the environment"]
  47. start = 5;
  48. for i in range(0,3):
  49. #draw(questions[i],start+i)
  50. draw2(questions[i],start+i)