statistic.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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.savefig(filename+".jpg",dpi=300)
  39. #plt.show()
  40. FileName = "Hector V2 Nutzerstudie.csv"
  41. file = pd.read_csv(FileName)
  42. colors = sns.color_palette()
  43. a = 0.6
  44. conditions = ["Handle","Lab","Remote","UI"]
  45. 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"]
  46. start = 5;
  47. for i in range(0,3):
  48. #draw(questions[i],start+i)
  49. draw2(questions[i],start+i)