elbow.py 726 B

12345678910111213141516171819202122232425262728293031
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. from mpl_toolkits.mplot3d import Axes3D
  4. fig = plt.figure()
  5. ax = fig.add_subplot(projection='3d', azim=30)
  6. with open("gains.txt", "r") as f:
  7. buf = f.read().split('\n')
  8. KI = []
  9. KP = []
  10. KD = []
  11. ACC = []
  12. for line in buf:
  13. if len(line)<4:
  14. continue
  15. cord = [round(float(i),2) for i in line.split(',')]
  16. acc = cord[0]
  17. kp = cord[1]
  18. ki = cord[2]
  19. kd = cord[3]
  20. KI+=[ki]
  21. KP+=[kp]
  22. KD+=[kd]
  23. ACC+=[acc]
  24. img = ax.scatter(KP, KI, KD, c=ACC, cmap=plt.hot())
  25. ax.set_xlabel("KP")
  26. ax.set_ylabel("KI")
  27. ax.set_zlabel("KD")
  28. fig.colorbar(img)
  29. plt.savefig("heuristics.png")
  30. #plt.show()