19
19
20
20
from . import config
21
21
from .bdalg import feedback
22
- from .ctrlplot import _add_arrows_to_line2D , _ctrlplot_rcParams , \
22
+ from .ctrlplot import ControlPlot , _add_arrows_to_line2D , _ctrlplot_rcParams , \
23
23
_find_axes_center , _get_line_labels , _make_legend_labels , \
24
24
_process_ax_keyword , _process_line_labels , _update_suptitle , suptitle
25
25
from .ctrlutil import unwrap
33
33
__all__ = ['bode_plot' , 'NyquistResponseData' , 'nyquist_response' ,
34
34
'nyquist_plot' , 'singular_values_response' ,
35
35
'singular_values_plot' , 'gangof4_plot' , 'gangof4_response' ,
36
- 'bode' , 'nyquist' , 'gangof4' ]
36
+ 'bode' , 'nyquist' , 'gangof4' , 'FrequencyResponseList' ]
37
37
38
38
# Default values for module parameter variables <
F438
/div>
39
39
_freqplot_defaults = {
@@ -124,10 +124,21 @@ def bode_plot(
124
124
125
125
Returns
126
126
-------
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.
131
142
132
143
Other Parameters
133
144
----------------
@@ -1008,7 +1019,7 @@ def gen_zero_centered_series(val_min, val_max, period):
1008
1019
else :
1009
1020
return mag_data , phase_data , omega_data
1010
1021
1011
- return out
1022
+ return ControlPlot ( out , ax_array , fig )
1012
1023
1013
1024
1014
1025
#
@@ -1483,16 +1494,27 @@ def nyquist_plot(
1483
1494
1484
1495
Returns
1485
1496
-------
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:
1491
1505
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.
1496
1518
1497
1519
Other Parameters
1498
1520
----------------
@@ -1923,7 +1945,7 @@ def _parse_linestyle(style_name, allow_false=False):
1923
1945
# Return counts and (optionally) the contour we used
1924
1946
return (counts , contours ) if return_contour else counts
1925
1947
1926
- return out
1948
+ return ControlPlot ( out , ax , fig )
1927
1949
1928
1950
1929
1951
#
@@ -2170,19 +2192,20 @@ def singular_values_plot(
2170
2192
2171
2193
Returns
2172
2194
-------
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.
2186
2209
2187
2210
Other Parameters
2188
2211
----------------
@@ -2193,6 +2216,9 @@ def singular_values_plot(
2193
2216
If present, replace automatically generated label(s) with the given
2194
2217
label(s). If sysdata is a list, strings should be specified for each
2195
2218
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.
2196
2222
omega_limits : array_like of two values
2197
2223
Set limits for plotted frequency range. If Hz=True the limits are
2198
2224
in Hz otherwise in rad/s. Specifying ``omega`` as a list of two
@@ -2213,6 +2239,16 @@ def singular_values_plot(
2213
2239
--------
2214
2240
singular_values_response
2215
2241
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
+
2216
2252
"""
2217
2253
# Keyword processing
2218
2254
dB = config ._get_param (
@@ -2363,7 +2399,7 @@ def singular_values_plot(
2363
2399
else :
2364
2400
return sigmas , omegas
2365
2401
2366
- return out
2402
+ return ControlPlot ( out , ax_sigma , fig )
2367
2403
2368
2404
#
2369
2405
# Utility functions
0 commit comments