@@ -431,15 +431,15 @@ various ways. The following general rules apply:
431
431
432
432
* If a plotting function is called multiple times with data that generate
433
433
control plots with the same shape for the array of subplots, the new data
434
- will be overlayed with the old data, with a change in color(s) for the
434
+ will be overlaid with the old data, with a change in color(s) for the
435
435
new data (chosen from the standard matplotlib color cycle). If not
436
436
overridden, the plot title and legends will be updated to reflect all
437
437
data shown on the plot.
438
438
439
439
* If a plotting function is called and the shape for the array of subplots
440
440
does not match the currently displayed plot, a new figure is created.
441
441
Note that only the shape is checked, so if two different types of
442
- plotting commands that generate the same shape of suplots are called
442
+ plotting commands that generate the same shape of subplots are called
443
443
sequentially, the :func: `matplotlib.pyplot.figure ` command should be used
444
444
to explicitly create a new figure.
445
445
@@ -485,7 +485,7 @@ various ways. The following general rules apply:
485
485
the ``legend_loc `` keyword argument is set to a string or integer, it
486
486
will set the position of the legend as described in the
487
487
:func: `matplotlib.legend` ` documentation. Finally, ``legend_map `` can be
488
- set to an` array that matches the shape of the suplots , with each item
488
+ set to an` array that matches the shape of the subplots , with each item
489
489
being a string indicating the location of the legend for that axes (or
490
490
``None `` for no legend).
491
491
@@ -530,6 +530,61 @@ various ways. The following general rules apply:
530
530
531
531
The plot title is only generated if ``ax `` is ``None ``.
532
532
533
+ The following code illustrates the use of some of these customization
534
+ features::
535
+
536
+ P = ct.tf([0.02], [1, 0.1, 0.01]) # servomechanism
537
+ C1 = ct.tf([1, 1], [1, 0]) # unstable
538
+ L1 = P * C1
539
+ C2 = ct.tf([1, 0.05], [1, 0]) # stable
540
+ L2 = P * C2
541
+
542
+ plt.rcParams.update(ct.rcParams)
543
+ fig = plt.figure(figsize=[7, 4])
544
+ ax_mag = fig.add_subplot(2, 2, 1)
545
+ ax_phase = fig.add_subplot(2, 2, 3)
546
+ ax_nyquist = fig.add_subplot(1, 2, 2)
547
+
548
+ ct.bode_plot(
549
+ [L1, L2], ax=[ax_mag, ax_phase],
550
+ label=["$L_1$ (unstable)", "$L_2$ (unstable)"],
551
+ show_legend=False)
552
+ ax_mag.set_title("Bode plot for $L_1$, $L_2$")
553
+ ax_mag.tick_params(labelbottom=False)
554
+ fig.align_labels()
555
+
556
+ ct.nyquist_plot(L1, ax=ax_nyquist, label="$L_1$ (unstable)")
557
+ ct.nyquist_plot(
558
+ L2, ax=ax_nyquist, label="$L_2$ (stable)",
559
+ max_curve_magnitude=22, legend_loc='upper right')
560
+ ax_nyquist.set_title("Nyquist plot for $L_1$, $L_2$")
561
+
562
+ fig.suptitle("Loop analysis for servomechanism control design")
563
+ plt.tight_layout()
564
+
565
+ .. image :: ctrlplot-servomech.png
566
+
567
+ As this example illustrates, python-control plotting functions and
568
+ Matplotlib plotting functions can generally be intermixed. One type of
569
+ plot for which this does not currently work is pole/zero plots with a
570
+ continuous time omega-damping grid (including root locus diagrams), due to
571
+ the way that axes grids are implemented. As a workaround, the
572
+ :func: `~control.pole_zero_subplots ` command can be used to create an array
573
+ of subplots with different grid types, as illustrated in the following
574
+ example::
575
+
576
+ ax_array = ct.pole_zero_subplots(2, 1, grid=[True, False])
577
+ sys1 = ct.tf([1, 2], [1, 2, 3], name='sys1')
578
+ sys2 = ct.tf([1, 0.2], [1, 1, 3, 1, 1], name='sys2')
579
+ ct.root_locus_plot([sys1, sys2], ax=ax_array[0, 0])
580
+ cplt = ct.root_locus_plot([sys1, sys2], ax=ax_array[1, 0])
581
+ cplt.set_plot_title("Root locus plots (w/ specified axes)")
582
+
583
+ .. image :: ctrlplot-pole_zero_subplots.png
584
+
585
+ Alternatively, turning off the omega-damping grid (using ``grid=False `` or
586
+ ``grid='empty' ``) allows use of Matplotlib layout commands.
587
+
533
588
534
589
Response and plotting functions
535
590
===============================
0 commit comments