Skip to content

Commit f818034

Browse files
committed
Fix suptitle for root locus plots
1 parent da5be15 commit f818034

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

control/pzmap.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
from numpy import cos, exp, imag, linspace, real, sin, sqrt
1919

2020
from . import config
21-
from .ctrlplot import ControlPlot, _get_line_labels
21+
from .ctrlplot import ControlPlot, suptitle, _get_line_labels, \
22+
_process_ax_keyword
2223
from .freqplot import _freqplot_defaults
2324
from .grid import nogrid, sgrid, zgrid
2425
from .iosys import isctime, isdtime
@@ -366,6 +367,7 @@ def pole_zero_plot(
366367

367368
# Handle color cycle manually as all root locus segments
368369
# of the same system are expected to be of the same color
370+
# TODO: replace with common function?
369371
color_cycle = plt.rcParams['axes.prop_cycle'].by_key()['color']
370372
color_offset = 0
371373
if len(ax.lines) > 0:
@@ -470,10 +472,10 @@ def pole_zero_plot(
470472

471473
# Add the title
472474
if title is None:
473-
title = "Pole/zero plot for " + ", ".join(labels)
475+
title = ("Root locus plot for " if rlocus_plot
476+
else "Pole/zero plot for ") + ", ".join(labels)
474477
if user_ax is None:
475-
with plt.rc_context(freqplot_rcParams):
476-
fig.suptitle(title)
478+
suptitle(title)
477479

478480
# Add dispather to handle choosing a point on the diagram
479481
if interactive:

control/tests/rlocus_test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,9 @@ def test_root_locus_documentation(savefigs=False):
278278
plt.figure()
279279
test_root_locus_plots(
280280
sys, grid=grid, xlim=xlim, ylim=ylim, interactive=interactive)
281+
ct.suptitle(
282+
f"sys={sys.name}, {grid=}, {xlim=}, {ylim=}, {interactive=}",
283+
frame='figure')
281284

282285
# Run tests that generate plots for the documentation
283286
test_root_locus_documentation(savefigs=True)

examples/plot_gallery.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ def invpend_update(t, x, u, params):
125125
sys2 = ct.tf([1, 0.2], [1, 1, 3, 1, 1], name='sys2')
126126
ct.root_locus_plot([sys1, sys2], grid=True, ax=ax1)
127127
ct.root_locus_plot([sys1, sys2], grid=False, ax=ax2)
128+
ct.suptitle("Root locus plots (w/ specified axes)")
128129
print(" -- BUG: should have 2 x 1 array of plots")
129130

130131
# sisotool

0 commit comments

Comments
 (0)