3939
4040# Define default parameter values for this module
4141_pzmap_defaults = {
42- 'pzmap.grid' : False , # Plot omega-damping grid
42+ 'pzmap.grid' : None , # Plot omega-damping grid
4343 'pzmap.marker_size' : 6 , # Size of the markers
4444 'pzmap.marker_width' : 1.5 , # Width of the markers
4545 'pzmap.expansion_factor' : 1.8 , # Amount to scale plots beyond features
@@ -111,20 +111,28 @@ def pole_zero_map(sysdata):
111111def pole_zero_plot (
112112 data , plot = None , grid = None , title = None , marker_color = None ,
113113 marker_size = None , marker_width = None , legend_loc = 'upper right' ,
114- xlim = None , ylim = None , interactive = False , ax = None , scaling = None ,
114+ xlim = None , ylim = None , interactive = None , ax = None , scaling = None ,
115115 initial_gain = None , ** kwargs ):
116116 # TODO: update docstring (see other response/plot functions for style)
117117 """Plot a pole/zero map for a linear system.
118118
119+ If the system data include root loci, a root locus diagram for the
120+ system is plotted. When the root locus for a single system is plotted,
121+ clicking on a location on the root locus will mark the gain on all
122+ branches of the diagram and show the system gain and damping for the
123+ given pole in the axes title. Set to False to turn off this behavior.
124+
119125 Parameters
120126 ----------
121- sysdata: List of PoleZeroData objects or LTI systems
127+ sysdata : List of PoleZeroData objects or LTI systems
122128 List of pole/zero response data objects generated by pzmap_response
123129 or rootlocus_response() that are to be plotted. If a list of systems
124130 is given, the poles and zeros of those systems will be plotted.
125- grid: boolean (default = False)
126- If True plot omega-damping grid.
127- plot: bool, optional
131+ grid : boolean (default = None)
132+ If True plot omega-damping grid, otherwise show imaginary axis for
133+ continuous time systems, unit circle for discrete time systems. If
134+ `False`, do not draw any additonal lines.
135+ plot : bool, optional
128136 (legacy) If ``True`` a graph is generated with Matplotlib,
129137 otherwise the poles and zeros are only computed and returned.
130138 If this argument is present, the legacy value of poles and
@@ -145,16 +153,42 @@ def pole_zero_plot(
145153 (legacy) If the `plot` keyword is given, the system poles and zeros
146154 are returned.
147155
148- Notes (TODO: update, including scaling)
156+ Other Parameters
157+ ----------------
158+ scaling : str or list, optional
159+ Set the type of axis scaling. Can be 'equal' (default), 'auto', or
160+ a list of the form [xmin, xmax, ymin, ymax].
161+ title : str, optional
162+ Set the title of the plot. Defaults plot type and system name(s).
163+ marker_color : str, optional
164+ Set the color of the markers used for poles and zeros.
165+ marker_color : int, optional
166+ Set the size of the markers used for poles and zeros.
167+ marker_width : int, optional
168+ Set the line width of the markers used for poles and zeros.
169+ legend_loc : str, optional
170+ For plots with multiple lines, a legend will be included in the
171+ given location. Default is 'center right'. Use False to supress.
172+ xlim : list, optional
173+ Set the limits for the x axis.
174+ ylim : list, optional
175+ Set the limits for the y axis.
176+ interactive : bool, optional
177+ Turn off interactive mode for root locus plots.
178+ initial_gain : float, optional
179+ If given, the specified system gain will be marked on the plot.
180+
181+ Notes
149182 -----
150- The pzmap function calls matplotlib.pyplot.axis('equal'), which means
151- that trying to reset the axis limits may not behave as expected. To
152- change the axis limits, use matplotlib.pyplot.gca().axis('auto') and
153- then set the axis limits to the desired values.
183+ By default, the pzmap function calls matplotlib.pyplot.axis('equal'),
184+ which means that trying to reset the axis limits may not behave as
185+ expected. To change the axis limits, use the `scaling` keyword of use
186+ matplotlib.pyplot.gca().axis('auto') and then set the axis limits to
187+ the desired values.
154188
155189 """
156190 # Get parameter values
157- grid = config ._get_param ('pzmap' , 'grid' , grid , False )
191+ grid = config ._get_param ('pzmap' , 'grid' , grid , None )
158192 marker_size = config ._get_param ('pzmap' , 'marker_size' , marker_size , 6 )
159193 marker_width = config ._get_param ('pzmap' , 'marker_width' , marker_width , 1.5 )
160194 xlim_user , ylim_user = xlim , ylim
@@ -177,6 +211,11 @@ def pole_zero_plot(
177211 else :
178212 raise TypeError ("unknown system data type" )
179213
214+ # Turn on interactive mode by default, if allowed
215+ if interactive is None and len (pzmap_responses ) == 1 \
216+ and pzmap_responses [0 ].sys is not None :
217+ interactive = True
218+
180219 # Legacy return value processing
181220 if plot is not None :
182221 warnings .warn (
@@ -217,11 +256,14 @@ def pole_zero_plot(
217256 ValueError (
218257 "incompatible time responses; don't know how to grid" )
219258 elif len (axs ) == 0 :
220- # use first response timebase
221- ax , fig = nogrid (data [0 ].dt , scaling = scaling )
259+ if grid is False :
260+ # Leave off grid entirely
261+ ax = plt .axes ()
262+ else :
263+ # use first response timebase
264+ ax , fig = nogrid (data [0 ].dt , scaling = scaling )
222265 else :
223266 # Use the existing axes and any grid that is there
224- # TODO: allow axis to be overriden via parameter
225267 ax = axs [0 ]
226268
227269 # Handle color cycle manually as all root locus segments
0 commit comments