()
| 130 | ###################################################################### |
| 131 | |
| 132 | def plot_motion(): |
| 133 | # Nominal motion |
| 134 | positions = gen_positions() |
| 135 | velocities = gen_deriv(positions) |
| 136 | accels = gen_deriv(velocities) |
| 137 | # Motion with pressure advance |
| 138 | pa_positions = calc_pa_raw(positions) |
| 139 | pa_velocities = gen_deriv(pa_positions) |
| 140 | # Smoothed motion |
| 141 | sm_positions = calc_pa(positions) |
| 142 | sm_velocities = gen_deriv(sm_positions) |
| 143 | # Build plot |
| 144 | times = [SEG_TIME * i for i in range(len(positions))] |
| 145 | trim_lists(times, velocities, accels, |
| 146 | pa_positions, pa_velocities, |
| 147 | sm_positions, sm_velocities) |
| 148 | fig, ax1 = matplotlib.pyplot.subplots(nrows=1, sharex=True) |
| 149 | ax1.set_title("Extruder Velocity") |
| 150 | ax1.set_ylabel('Velocity (mm/s)') |
| 151 | pa_plot, = ax1.plot(times, pa_velocities, 'r', |
| 152 | label='Pressure Advance', alpha=0.3) |
| 153 | nom_plot, = ax1.plot(times, velocities, 'black', label='Nominal') |
| 154 | sm_plot, = ax1.plot(times, sm_velocities, 'g', label='Smooth PA', alpha=0.9) |
| 155 | fontP = matplotlib.font_manager.FontProperties() |
| 156 | fontP.set_size('x-small') |
| 157 | ax1.legend(handles=[nom_plot, pa_plot, sm_plot], loc='best', prop=fontP) |
| 158 | ax1.set_xlabel('Time (s)') |
| 159 | ax1.grid(True) |
| 160 | fig.tight_layout() |
| 161 | return fig |
| 162 | |
| 163 | def setup_matplotlib(output_to_file): |
| 164 | global matplotlib |
no test coverage detected