daily pastebin goal
76%
SHARE
TWEET

Untitled

a guest Dec 18th, 2017 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. fig = plt.figure(1, figsize=(10,10))
  2. fig.clf()
  3. ax = fig.add_subplot(111)
  4.  
  5. #Loading dataset files
  6. left_250_20 = sorted(glob.iglob('./250_20/left_new/*.log'))
  7.  
  8. legends3 = []
  9. last_positions = np.zeros((len(left_250_20), 2))
  10.  
  11. for file in range(len(left_250_20)):
  12.     legends3.append("{} trace".format(file))
  13.     f = open(left_250_20[file],"r")
  14.     lines = f.readlines()
  15.     x = []
  16.     y = []
  17.  
  18.     for i in lines:
  19.         x.append(i.split(' ')[2])
  20.         y.append(i.split(' ')[3])
  21.     f.close()
  22.  
  23.     x = np.asarray(x, dtype=float)
  24.     x = -1*x + x[0]
  25.     y = np.asarray(y, dtype=float)
  26.     y = -1*y + y[0]
  27.     last_positions[file, 0] = x[-1]
  28.     last_positions[file, 1] = y[-1]
  29.     ax.plot(x,y, marker='o', linestyle='--', markersize=5)
  30.  
  31. average_x = np.average(last_positions[:,0])
  32. average_y = np.average(last_positions[:,1])
  33. difference = np.sqrt((average_x - trajectory_250_20_l[-1,0])**2 + (average_y - trajectory_250_20_l[-1,1])**2)
  34. print(difference)
  35. ax.plot(trajectory_250_20_l[:,0], trajectory_250_20_l[:,1], marker='o', linestyle='--', markersize=15)
  36. ax.plot(average_x, average_y, marker='o', linestyle='--', markersize=15)
  37. plt.xlabel('x (mm)',fontsize=34)
  38. plt.ylabel('y (mm)',fontsize=34)
  39. plt.xticks(fontsize=24)
  40. plt.yticks(fontsize=24)
  41. x_start, x_end = ax.get_xlim()
  42. y_start, y_end = ax.get_ylim()
  43. plt.axis('equal')
  44. plt.grid()
  45. plt.savefig('left_250_20.png')
  46. plt.show()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top