Cheetah Software  1.0
plot_spline_1d.py
Go to the documentation of this file.
1 import numpy as np
2 import matplotlib
3 matplotlib.use('TkAgg')
4 import matplotlib.pyplot as plt
5 import os
6 
7 # Plot configuration
8 PLOT_VERTICALLY = 0
9 PLOT_HORIZONTALLY = 1
10 
11 # number of figures in this plot
12 num_figures = 5
13 
14 def create_figures(subfigure_width=480, subfigure_height=600, starting_figure_no=1, starting_col_index = 0, starting_row_index=0, plot_configuration=PLOT_HORIZONTALLY):
15  figure_number = starting_figure_no
16  col_index = starting_col_index
17  row_index = starting_row_index
18 
19  file_path = os.getcwd() + "/../test_data/"
20 
21  ## read files
22  bspline = np.genfromtxt(file_path+'bspline_1d.txt', delimiter=None, dtype=(float))
23  bs_t = np.genfromtxt(file_path+'bs_time_1d.txt', delimiter='\n', dtype=(float))
24 
25  ## plot bspline
26  fig = plt.figure(figure_number)
27  plt.get_current_fig_manager().window.wm_geometry(str(subfigure_width) + "x" + str(subfigure_height) + "+" + str(subfigure_width*col_index) + "+" + str(subfigure_height*row_index))
28  fig.canvas.set_window_title('bspline_pos_vel_acc')
29  for i in range(3):
30  ax1 = plt.subplot(3, 1, i+1)
31  plt.plot(bs_t, bspline[:,i], "b-")
32  plt.grid(True)
33  plt.xlabel('time (sec)')
34  ## increment figure number and index
35  figure_number += 1
36  if plot_configuration == PLOT_HORIZONTALLY:
37  col_index += 1
38  elif plot_configuration == PLOT_VERTICALLY:
39  row_index +=1
40 
41 if __name__ == "__main__":
43  plt.show()
def create_figures(subfigure_width=480, subfigure_height=600, starting_figure_no=1, starting_col_index=0, starting_row_index=0, plot_configuration=PLOT_HORIZONTALLY)