4040# SUCH DAMAGE.
4141#
4242# $Id$
43+
44+ import math
45+
4346import matplotlib as mpl
4447import matplotlib .pyplot as plt
45- import scipy as sp
4648import numpy as np
47- import math
49+
4850from .ctrlutil import unwrap
4951from .bdalg import feedback
5052from .margins import stability_margins
@@ -110,9 +112,9 @@ def bode_plot(syslist, omega=None,
110112 config.defaults['freqplot.number_of_samples'].
111113 margins : bool
112114 If True, plot gain and phase margin.
113- *args : `matplotlib` plot positional properties, optional
115+ *args : :func: `matplotlib.pyplot. plot` positional properties, optional
114116 Additional arguments for `matplotlib` plots (color, linestyle, etc)
115- **kwargs : `matplotlib` plot keyword properties, optional
117+ **kwargs : :func: `matplotlib.pyplot. plot` keyword properties, optional
116118 Additional keywords (passed to `matplotlib`)
117119
118120 Returns
@@ -128,21 +130,22 @@ def bode_plot(syslist, omega=None,
128130 ----------------
129131 grid : bool
130132 If True, plot grid lines on gain and phase plots. Default is set by
131- config.defaults['bode.grid'].
133+ `config.defaults['bode.grid']`.
134+
132135
133136 The default values for Bode plot configuration parameters can be reset
134137 using the `config.defaults` dictionary, with module name 'bode'.
135138
136139 Notes
137140 -----
138- 1. Alternatively, you may use the lower-level method (mag, phase, freq)
139- = sys.freqresp(freq) to generate the frequency response for a system,
140- but it returns a MIMO response.
141+ 1. Alternatively, you may use the lower-level method
142+ ``(mag, phase, freq) = sys.freqresp(freq)`` to generate the frequency
143+ response for a system, but it returns a MIMO response.
141144
142145 2. If a discrete time model is given, the frequency response is plotted
143- along the upper branch of the unit circle, using the mapping z = exp(j
144- \\ omega dt) where omega ranges from 0 to pi/dt and dt is the discrete
145- timebase. If not timebase is specified (dt = True), dt is set to 1.
146+ along the upper branch of the unit circle, using the mapping z = exp(j
147+ \\ omega dt) where omega ranges from 0 to pi/dt and dt is the discrete
148+ timebase. If not timebase is specified (dt = True), dt is set to 1.
146149
147150 Examples
148151 --------
@@ -183,12 +186,12 @@ def bode_plot(syslist, omega=None,
183186 if Hz :
184187 omega_limits *= 2. * math .pi
185188 if omega_num :
186- omega = sp .logspace (np .log10 (omega_limits [0 ]),
189+ omega = np .logspace (np .log10 (omega_limits [0 ]),
187190 np .log10 (omega_limits [1 ]),
188191 num = omega_num ,
189192 endpoint = True )
190193 else :
191- omega = sp .logspace (np .log10 (omega_limits [0 ]),
194+ omega = np .logspace (np .log10 (omega_limits [0 ]),
192195 np .log10 (omega_limits [1 ]),
193196 endpoint = True )
194197
@@ -464,9 +467,9 @@ def nyquist_plot(syslist, omega=None, plot=True, label_freq=0,
464467 Label every nth frequency on the plot
465468 arrowhead_width : arrow head width
466469 arrowhead_length : arrow head length
467- *args : `matplotlib` plot positional properties, optional
470+ *args : :func: `matplotlib.pyplot. plot` positional properties, optional
468471 Additional arguments for `matplotlib` plots (color, linestyle, etc)
469- **kwargs : `matplotlib` plot keyword properties, optional
472+ **kwargs : :func: `matplotlib.pyplot. plot` keyword properties, optional
470473 Additional keywords (passed to `matplotlib`)
471474
472475 Returns
@@ -529,8 +532,8 @@ def nyquist_plot(syslist, omega=None, plot=True, label_freq=0,
529532 phase = np .squeeze (phase_tmp )
530533
531534 # Compute the primary curve
532- x = sp .multiply (mag , sp .cos (phase ))
533- y = sp .multiply (mag , sp .sin (phase ))
535+ x = np .multiply (mag , np .cos (phase ))
536+ y = np .multiply (mag , np .sin (phase ))
534537
535538 if plot :
536539 # Plot the primary curve and mirror image
@@ -539,13 +542,13 @@ def nyquist_plot(syslist, omega=None, plot=True, label_freq=0,
539542 ax = plt .gca ()
540543 # Plot arrow to indicate Nyquist encirclement orientation
541544 ax .arrow (x [0 ], y [0 ], (x [1 ]- x [0 ])/ 2 , (y [1 ]- y [0 ])/ 2 , fc = c , ec = c ,
542- head_width = arrowhead_width ,
545+ head_width = arrowhead_width ,
543546 head_length = arrowhead_length )
544547
545548 plt .plot (x , - y , '-' , color = c , * args , ** kwargs )
546549 ax .arrow (
547550 x [- 1 ], - y [- 1 ], (x [- 1 ]- x [- 2 ])/ 2 , (y [- 1 ]- y [- 2 ])/ 2 ,
548- fc = c , ec = c , head_width = arrowhead_width ,
551+ fc = c , ec = c , head_width = arrowhead_width ,
549552 head_length = arrowhead_length )
550553
551554 # Mark the -1 point
@@ -556,7 +559,7 @@ def nyquist_plot(syslist, omega=None, plot=True, label_freq=0,
556559 ind = slice (None , None , label_freq )
557560 for xpt , ypt , omegapt in zip (x [ind ], y [ind ], omega [ind ]):
558561 # Convert to Hz
559- f = omegapt / (2 * sp .pi )
562+ f = omegapt / (2 * np .pi )
560563
561564 # Factor out multiples of 1000 and limit the
562565 # result to the range [-8, 8].
@@ -601,7 +604,7 @@ def gangof4_plot(P, C, omega=None, **kwargs):
601604 Linear input/output systems (process and control)
602605 omega : array
603606 Range of frequencies (list or bounds) in rad/sec
604- **kwargs : `matplotlib` plot keyword properties, optional
607+ **kwargs : :func: `matplotlib.pyplot. plot` keyword properties, optional
605608 Additional keywords (passed to `matplotlib`)
606609
607610 Returns
0 commit comments