|
151 | 151 | "outputs": [], |
152 | 152 | "source": [ |
153 | 153 | "response = ct.initial_response(sys, X0=[1, 0, 0, 0])\n", |
154 | | - "out = response.plot()" |
| 154 | + "cplt = response.plot()" |
155 | 155 | ] |
156 | 156 | }, |
157 | 157 | { |
|
195 | 195 | "metadata": {}, |
196 | 196 | "outputs": [], |
197 | 197 | "source": [ |
198 | | - "# Do some Python magic to get different colors\n", |
199 | | - "from itertools import cycle\n", |
200 | | - "prop_cycle = plt.rcParams['axes.prop_cycle']\n", |
201 | | - "colors = cycle(prop_cycle.by_key()['color'])\n", |
202 | | - "\n", |
203 | 198 | "for X0 in [[1, 0, 0, 0], [0, 2, 0, 0], [1, 2, 0, 0], [0, 0, 1, 0], [0, 0, 2, 0]]:\n", |
204 | 199 | " response = ct.initial_response(sys, T=20, X0=X0)\n", |
205 | | - " try:\n", |
206 | | - " response.plot(color=next(colors), label=f\"{X0=}\")\n", |
207 | | - " except TypeError:\n", |
208 | | - " # Earlier versions of python-control don't allow relabeling\n", |
209 | | - " response.sysname = f\"{X0=}\"\n", |
210 | | - " response.plot(color=next(colors))" |
| 200 | + " response.plot(label=f\"{X0=}\")" |
211 | 201 | ] |
212 | 202 | }, |
213 | 203 | { |
|
227 | 217 | "metadata": {}, |
228 | 218 | "outputs": [], |
229 | 219 | "source": [ |
230 | | - "out = ct.step_response(sys).plot()" |
| 220 | + "cplt = ct.step_response(sys).plot()" |
231 | 221 | ] |
232 | 222 | }, |
233 | 223 | { |
|
267 | 257 | "outputs": [], |
268 | 258 | "source": [ |
269 | 259 | "stepresp = ct.step_response(sys)\n", |
270 | | - "out = stepresp.plot(plot_inputs=True)" |
| 260 | + "cplt = stepresp.plot(plot_inputs=True)" |
271 | 261 | ] |
272 | 262 | }, |
273 | 263 | { |
|
277 | 267 | "outputs": [], |
278 | 268 | "source": [ |
279 | 269 | "# Plot the inputs on top of the outputs\n", |
280 | | - "out = stepresp.plot(plot_inputs='overlay')" |
| 270 | + "cplt = stepresp.plot(plot_inputs='overlay')" |
281 | 271 | ] |
282 | 272 | }, |
283 | 273 | { |
|
331 | 321 | "outputs": [], |
332 | 322 | "source": [ |
333 | 323 | "# Show that the system response is linear\n", |
334 | | - "out = resp3.plot()\n", |
335 | | - "axs = ct.get_plot_axes(out)\n", |
336 | | - "axs[0, 0].plot(resp1.time, resp1.outputs[0] + resp2.outputs[0], 'k--')\n", |
337 | | - "axs[1, 0].plot(resp1.time, resp1.outputs[1] + resp2.outputs[1], 'k--')\n", |
338 | | - "axs[2, 0].plot(resp1.time, resp1.inputs[0] + resp2.inputs[0], 'k--');" |
| 324 | + "cplt = resp3.plot()\n", |
| 325 | + "cplt.axes[0, 0].plot(resp1.time, resp1.outputs[0] + resp2.outputs[0], 'k--')\n", |
| 326 | + "cplt.axes[1, 0].plot(resp1.time, resp1.outputs[1] + resp2.outputs[1], 'k--')\n", |
| 327 | + "cplt.axes[2, 0].plot(resp1.time, resp1.inputs[0] + resp2.inputs[0], 'k--');" |
339 | 328 | ] |
340 | 329 | }, |
341 | 330 | { |
|
350 | 339 | "resp2 = ct.forced_response(sys, T, U2, X0=X0)\n", |
351 | 340 | "resp3 = ct.forced_response(sys, T, U1 + U2, X0=X0)\n", |
352 | 341 | "\n", |
353 | | - "out = resp3.plot()\n", |
354 | | - "axs = ct.get_plot_axes(out)\n", |
355 | | - "axs[0, 0].plot(resp1.time, resp1.outputs[0] + resp2.outputs[0], 'k--')\n", |
356 | | - "axs[1, 0].plot(resp1.time, resp1.outputs[1] + resp2.outputs[1], 'k--')\n", |
357 | | - "axs[2, 0].plot(resp1.time, resp1.inputs[0] + resp2.inputs[0], 'k--');" |
| 342 | + "cplt = resp3.plot()\n", |
| 343 | + "cplt.axes[0, 0].plot(resp1.time, resp1.outputs[0] + resp2.outputs[0], 'k--')\n", |
| 344 | + "cplt.axes[1, 0].plot(resp1.time, resp1.outputs[1] + resp2.outputs[1], 'k--')\n", |
| 345 | + "cplt.axes[2, 0].plot(resp1.time, resp1.inputs[0] + resp2.inputs[0], 'k--');" |
358 | 346 | ] |
359 | 347 | }, |
360 | 348 | { |
|
375 | 363 | "# Manual computation of the frequency response\n", |
376 | 364 | "resp = ct.input_output_response(sys, T, np.sin(1.35 * T))\n", |
377 | 365 | "\n", |
378 | | - "try:\n", |
379 | | - " out = resp.plot(\n", |
| 366 | + "cplt = resp.plot(\n", |
380 | 367 | " plot_inputs='overlay', \n", |
381 | 368 | " legend_map=np.array([['lower left'], ['lower left']]),\n", |
382 | | - " label=[['q1', 'u[0]'], ['q2', None]])\n", |
383 | | - "except TypeError:\n", |
384 | | - " # Earlier versions of python-control don't allow relabeling\n", |
385 | | - " out = resp.plot(\n", |
386 | | - " plot_inputs='overlay',\n", |
387 | | - " legend_map=np.array([['lower left'], ['lower left']]))" |
| 369 | + " label=[['q1', 'u[0]'], ['q2', None]])" |
388 | 370 | ] |
389 | 371 | }, |
390 | 372 | { |
|
457 | 439 | "outputs": [], |
458 | 440 | "source": [ |
459 | 441 | "freqresp = ct.frequency_response(sys)\n", |
460 | | - "out = freqresp.plot()" |
| 442 | + "cplt = freqresp.plot()" |
461 | 443 | ] |
462 | 444 | }, |
463 | 445 | { |
|
477 | 459 | "metadata": {}, |
478 | 460 | "outputs": [], |
479 | 461 | "source": [ |
480 | | - "out = ct.bode_plot(sys, overlay_outputs=True)" |
| 462 | + "cplt = ct.bode_plot(sys, overlay_outputs=True)" |
481 | 463 | ] |
482 | 464 | }, |
483 | 465 | { |
|
497 | 479 | "metadata": {}, |
498 | 480 | "outputs": [], |
499 | 481 | "source": [ |
500 | | - "out = ct.frequency_response(\n", |
| 482 | + "cplt = ct.frequency_response(\n", |
501 | 483 | " coupled.linearize([0, 0, 0, 0], [0], params={'c': 0.01})\n", |
502 | 484 | ").plot(overlay_outputs=True)" |
503 | 485 | ] |
|
0 commit comments