1919
2020from . import config
2121from .bdalg import feedback
22- from .ctrlplot import _add_arrows_to_line2D , _ctrlplot_rcParams , \
22+ from .ctrlplot import ControlPlot , _add_arrows_to_line2D , _ctrlplot_rcParams , \
2323 _find_axes_center , _get_line_labels , _make_legend_labels , \
2424 _process_ax_keyword , _process_line_labels , _update_suptitle , suptitle
2525from .ctrlutil import unwrap
3333__all__ = ['bode_plot' , 'NyquistResponseData' , 'nyquist_response' ,
3434 'nyquist_plot' , 'singular_values_response' ,
3535 'singular_values_plot' , 'gangof4_plot' , 'gangof4_response' ,
36- 'bode' , 'nyquist' , 'gangof4' ]
36+ 'bode' , 'nyquist' , 'gangof4' , 'FrequencyResponseList' ]
3737
3838# Default values for module parameter variables
3939_freqplot_defaults = {
@@ -124,10 +124,21 @@ def bode_plot(
124124
125125 Returns
126126 -------
127- lines : array of Line2D
128- Array of Line2D objects for each line in the plot. The shape of
129- the array matches the subplots shape and the value of the array is a
130- list of Line2D objects in that subplot.
127+ cplt : :class:`ControlPlot` object
128+ Object containing the data that were plotted:
129+
130+ * cplt.lines: Array of :class:`matplotlib.lines.Line2D` objects
131+ for each line in the plot. The shape of the array matches the
132+ subplots shape and the value of the array is a list of Line2D
133+ objects in that subplot.
134+
135+ * cplt.axes: 2D array of :class:`matplotlib.axes.Axes` for the plot.
136+
137+ * cplt.figure: :class:`matplotlib.figure.Figure` containing the plot.
138+
139+ * cplt.legend: legend object(s) contained in the plot
140+
141+ See :class:`ControlPlot` for more detailed information.
131142
132143 Other Parameters
133144 ----------------
@@ -1008,7 +1019,7 @@ def gen_zero_centered_series(val_min, val_max, period):
10081019 else :
10091020 return mag_data , phase_data , omega_data
10101021
1011- return out
1022+ return ControlPlot ( out , ax_array , fig )
10121023
10131024
10141025#
@@ -1483,16 +1494,27 @@ def nyquist_plot(
14831494
14841495 Returns
14851496 -------
1486- lines : array of Line2D
1487- 2D array of Line2D objects for each line in the plot. The shape of
1488- the array is given by (nsys, 4) where nsys is the number of systems
1489- or Nyquist responses passed to the function. The second index
1490- specifies the segment type:
1497+ cplt : :class:`ControlPlot` object
1498+ Object containing the data that were plotted:
1499+
1500+ * cplt.lines: 2D array of :class:`matplotlib.lines.Line2D`
1501+ objects for each line in the plot. The shape of the array is
1502+ given by (nsys, 4) where nsys is the number of systems or
1503+ Nyquist responses passed to the function. The second index
1504+ specifies the segment type:
14911505
1492- * lines[idx, 0]: unscaled portion of the primary curve
1493- * lines[idx, 1]: scaled portion of the primary curve
1494- * lines[idx, 2]: unscaled portion of the mirror curve
1495- * lines[idx, 3]: scaled portion of the mirror curve
1506+ - lines[idx, 0]: unscaled portion of the primary curve
1507+ - lines[idx, 1]: scaled portion of the primary curve
1508+ - lines[idx, 2]: unscaled portion of the mirror curve
1509+ - lines[idx, 3]: scaled portion of the mirror curve
1510+
1511+ * cplt.axes: 2D array of :class:`matplotlib.axes.Axes` for the plot.
1512+
1513+ * cplt.figure: :class:`matplotlib.figure.Figure` containing the plot.
1514+
1515+ * cplt.legend: legend object(s) contained in the plot
1516+
1517+ See :class:`ControlPlot` for more detailed information.
14961518
14971519 Other Parameters
14981520 ----------------
@@ -1923,7 +1945,7 @@ def _parse_linestyle(style_name, allow_false=False):
19231945 # Return counts and (optionally) the contour we used
19241946 return (counts , contours ) if return_contour else counts
19251947
1926- return out
1948+ return ControlPlot ( out , ax , fig )
19271949
19281950
19291951#
@@ -2170,19 +2192,20 @@ def singular_values_plot(
21702192
21712193 Returns
21722194 -------
2173- legend_loc : str, optional
2174- For plots with multiple lines, a legend will be included in the
2175- given location. Default is 'center right'. Use False to suppress.
2176- lines : array of Line2D
2177- 1-D array of Line2D objects. The size of the array matches
2178- the number of systems and the value of the array is a list of
2179- Line2D objects for that system.
2180- mag : ndarray (or list of ndarray if len(data) > 1))
2181- If plot=False, magnitude of the response (deprecated).
2182- phase : ndarray (or list of ndarray if len(data) > 1))
2183- If plot=False, phase in radians of the response (deprecated).
2184- omega : ndarray (or list of ndarray if len(data) > 1))
2185- If plot=False, frequency in rad/sec (deprecated).
2195+ cplt : :class:`ControlPlot` object
2196+ Object containing the data that were plotted:
2197+
2198+ * cplt.lines: 1-D array of :class:`matplotlib.lines.Line2D` objects.
2199+ The size of the array matches the number of systems and the
2200+ value of the array is a list of Line2D objects for that system.
2201+
2202+ * cplt.axes: 2D array of :class:`matplotlib.axes.Axes` for the plot.
2203+
2204+ * cplt.figure: :class:`matplotlib.figure.Figure` containing the plot.
2205+
2206+ * cplt.legend: legend object(s) contained in the plot
2207+
2208+ See :class:`ControlPlot` for more detailed information.
21862209
21872210 Other Parameters
21882211 ----------------
@@ -2193,6 +2216,9 @@ def singular_values_plot(
21932216 If present, replace automatically generated label(s) with the given
21942217 label(s). If sysdata is a list, strings should be specified for each
21952218 system.
2219+ legend_loc : str, optional
2220+ For plots with multiple lines, a legend will be included in the
2221+ given location. Default is 'center right'. Use False to supress.
21962222 omega_limits : array_like of two values
21972223 Set limits for plotted frequency range. If Hz=True the limits are
21982224 in Hz otherwise in rad/s. Specifying ``omega`` as a list of two
@@ -2213,6 +2239,16 @@ def singular_values_plot(
22132239 --------
22142240 singular_values_response
22152241
2242+ Notes
2243+ -----
2244+ 1. If plot==False, the following legacy values are returned:
2245+ * mag : ndarray (or list of ndarray if len(data) > 1))
2246+ Magnitude of the response (deprecated).
2247+ * phase : ndarray (or list of ndarray if len(data) > 1))
2248+ Phase in radians of the response (deprecated).
2249+ * omega : ndarray (or list of ndarray if len(data) > 1))
2250+ Frequency in rad/sec (deprecated).
2251+
22162252 """
22172253 # Keyword processing
22182254 dB = config ._get_param (
@@ -2363,7 +2399,7 @@ def singular_values_plot(
23632399 else :
23642400 return sigmas , omegas
23652401
2366- return out
2402+ return ControlPlot ( out , ax_sigma , fig )
23672403
23682404#
23692405# Utility functions
0 commit comments