6464# sysnames = [response.sysname for response in data]
6565# if title is None:
6666# title = "Name plot for " + ", ".join(sysnames)
67- # _update_suptitle (title, fig, rcParams=rcParams)
68- # else
69- # suptitle (title, fig, rcParams=rcParams)
67+ # _update_plot_title (title, fig, rcParams=rcParams)
68+ # else:
69+ # _update_plot_title (title, fig, rcParams=rcParams, use_existing=False )
7070#
7171# # Legacy processing of plot keyword
7272# if plot is True:
@@ -162,7 +162,28 @@ def reshape(self, *args):
162162 return self .lines .reshape (* args )
163163
164164 def set_plot_title (self , title , frame = 'axes' ):
165- suptitle (title , fig = self .figure , frame = frame )
165+ """Set the title for a control plot.
166+
167+ This is a wrapper for the matplotlib `suptitle` function, but by
168+ setting ``frame`` to 'axes' (default) then the title is centered on
169+ the midpoint of the axes in the figure, rather than the center of
170+ the figure. This usually looks better (particularly with
171+ multi-panel plots), though it takes longer to render.
172+
173+ Parameters
174+ ----------
175+ title : str
176+ Title text.
177+ fig : Figure, optional
178+ Matplotlib figure. Defaults to current figure.
179+ frame : str, optional
180+ Coordinate frame to use for centering: 'axes' (default) or 'figure'.
181+ **kwargs : :func:`matplotlib.pyplot.suptitle` keywords, optional
182+ Additional keywords (passed to matplotlib).
183+
184+ """
185+ _update_plot_title (
186+ title , fig = self .figure , frame = frame , use_existing = False )
166187
167188
168189#
@@ -177,42 +198,13 @@ def suptitle(
177198 title , fig = None , frame = 'axes' , ** kwargs ):
178199 """Add a centered title to a figure.
179200
180- This is a wrapper for the matplotlib `suptitle` function, but by
181- setting ``frame`` to 'axes' (default) then the title is centered on the
182- midpoint of the axes in the figure, rather than the center of the
183- figure. This usually looks better (particularly with multi-panel
184- plots), though it takes longer to render.
185-
186- Parameters
187- ----------
188- title : str
189- Title text.
190- fig : Figure, optional
191- Matplotlib figure. Defaults to current figure.
192- frame : str, optional
193- Coordinate frame to use for centering: 'axes' (default) or 'figure'.
194- **kwargs : :func:`matplotlib.pyplot.suptitle` keywords, optional
195- Additional keywords (passed to matplotlib).
201+ This function is deprecated. Use :func:`ControlPlot.set_plot_title`.
196202
197203 """
198- rcParams = config ._get_param ('ctrlplot' , 'rcParams' , kwargs , pop = True )
199-
200- if fig is None :
201- fig = plt .gcf ()
202-
203- if frame == 'figure' :
204- with plt .rc_context (rcParams ):
205- fig .suptitle (title , ** kwargs )
206-
207- elif frame == 'axes' :
208- with plt .rc_context (rcParams ):
209- fig .suptitle (title , ** kwargs ) # Place title in center
210- plt .tight_layout () # Put everything into place
211- xc , _ = _find_axes_center (fig , fig .get_axes ())
212- fig .suptitle (title , x = xc , ** kwargs ) # Redraw title, centered
213-
214- else :
215- raise ValueError (f"unknown frame '{ frame } '" )
204+ warnings .warn (
205+ "suptitle is deprecated; use cplt.set_plot_title" , FutureWarning )
206+ _update_plot_title (
207+ title , fig = fig , frame = frame , use_existing = False , ** kwargs )
216208
217209
218210# Create vectorized function to find axes from lines
@@ -472,8 +464,18 @@ def _make_legend_labels(labels, ignore_common=False):
472464 return labels
473465
474466
475- def _update_suptitle (title , fig = None , frame = 'axes' , rcParams = None ):
476- if fig is not None and isinstance (title , str ):
467+ def _update_plot_title (
468+ title , fig = None , frame = 'axes' , use_existing = True , ** kwargs ):
469+ if title is False :
470+ return
471+ if fig is None :
472+ fig = plt .gcf ()
473+ rcParams = config ._get_param ('ctrlplot' , 'rcParams' , kwargs , pop = True )
474+ if rcParams is None :
475+ rcParams = _ctrlplot_rcParams
476+ print (f"{ rcParams ['figure.titlesize' ]= } " )
477+
478+ if use_existing :
477479 # Get the current title, if it exists
478480 old_title = None if fig ._suptitle is None else fig ._suptitle ._text
479481
@@ -492,8 +494,19 @@ def _update_suptitle(title, fig=None, frame='axes', rcParams=None):
492494 separator = ',' if len (common_prefix ) > 0 else ';'
493495 title = old_title + separator + title [common_len :]
494496
495- # Add the title
496- suptitle (title , fig = fig , rcParams = rcParams , frame = frame )
497+ if frame == 'figure' :
498+ with plt .rc_context (rcParams ):
499+ fig .suptitle (title , ** kwargs )
500+
501+ elif frame == 'axes' :
502+ with plt .rc_context (rcParams ):
503+ fig .suptitle (title , ** kwargs ) # Place title in center
504+ plt .tight_layout () # Put everything into place
505+ xc , _ = _find_axes_center (fig , fig .get_axes ())
506+ fig .suptitle (title , x = xc , ** kwargs ) # Redraw title, centered
507+
508+ else :
509+ raise ValueError (f"unknown frame '{ frame } '" )
497510
498511
499512def _find_axes_center (fig , axs ):
0 commit comments