Skip to content

Commit ad40832

Browse files
committed
added soft exclusion logic for streamlines, vectorfield and streamplot and fixed minor documentation issues
1 parent 03c3b35 commit ad40832

File tree

1 file changed

+27
-15
lines changed

1 file changed

+27
-15
lines changed

control/phaseplot.py

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,16 @@
4747

4848
def phase_plane_plot(
4949
sys, pointdata=None, timedata=None, gridtype=None, gridspec=None,
50-
plot_streamlines=True, plot_vectorfield=False, plot_equilpoints=True,
51-
plot_separatrices=True, ax=None, suppress_warnings=False, title=None,
52-
plot_streamplot=False, **kwargs
50+
plot_streamlines=None, plot_vectorfield=None, plot_streamplot=None,
51+
plot_equilpoints=True, plot_separatrices=True, ax=None,
52+
suppress_warnings=False, title=None, **kwargs
5353
):
5454
"""Plot phase plane diagram.
5555
5656
This function plots phase plane data, including vector fields, stream
5757
lines, equilibrium points, and contour curves.
58+
If none of plot_streamlines, plot_vectorfield, or plot_streamplot are
59+
set, then plot_streamlines is used by default.
5860
5961
Parameters
6062
----------
@@ -129,15 +131,15 @@ def phase_plane_plot(
129131
'both' to flow both forward and backward. The amount of time to
130132
simulate in each direction is given by the `timedata` argument.
131133
plot_streamlines : bool or dict, optional
132-
If True (default) then plot streamlines based on the pointdata
133-
and gridtype. If set to a dict, pass on the key-value pairs in
134-
the dict as keywords to `streamlines`.
134+
If then plot streamlines based on the pointdata and gridtype. If set
135+
to a dict, pass on the key-value pairs in the dict as keywords to
136+
`streamlines`.
135137
plot_vectorfield : bool or dict, optional
136-
If True (default) then plot the vector field based on the pointdata
137-
and gridtype. If set to a dict, pass on the key-value pairs in
138-
the dict as keywords to `phaseplot.vectorfield`.
138+
If then plot the vector field based on the pointdata and gridtype.
139+
If set to a dict, pass on the key-value pairs in the dict as keywords
140+
to `phaseplot.vectorfield`.
139141
plot_streamplot : bool or dict, optional
140-
If True then use :func:`matplotlib.axes.Axes.streamplot` function
142+
If then use :func:`matplotlib.axes.Axes.streamplot` function
141143
to plot the streamlines. If set to a dict, pass on the key-value
142144
pairs in the dict as keywords to :func:`~control.phaseplot.streamplot`.
143145
plot_equilpoints : bool or dict, optional
@@ -157,6 +159,16 @@ def phase_plane_plot(
157159
Set the title of the plot. Defaults to plot type and system name(s).
158160
159161
"""
162+
if (
163+
plot_streamlines is None
164+
and plot_vectorfield is None
165+
and plot_streamplot is None
166+
):
167+
plot_streamlines = True
168+
169+
if plot_streamplot and not plot_streamlines and not plot_vectorfield:
170+
gridspec = gridspec or [25, 25]
171+
160172
# Process arguments
161173
params = kwargs.get('params', None)
162174
sys = _create_system(sys, params)
@@ -378,20 +390,20 @@ def streamplot(
378390
Plot the vector field in the given color.
379391
vary_color : bool, optional
380392
If set to True, vary the color of the streamlines based on the magnitude
381-
vary_linewidth : bool, optional
382-
If set to True, vary the linewidth of the streamlines based on the magnitude
393+
vary_linewidth : bool, optional.
394+
If set to True, vary the linewidth of the streamlines based on the magnitude.
383395
cmap : str or Colormap, optional
384-
Colormap to use for varying the color of the streamlines
396+
Colormap to use for varying the color of the streamlines.
385397
norm : `matplotlib.colors.Normalize`, optional
386-
An instance of Normalize to use for scaling the colormap and linewidths
398+
An instance of Normalize to use for scaling the colormap and linewidths.
387399
ax : `matplotlib.axes.Axes`, optional
388400
Use the given axes for the plot, otherwise use the current axes.
389401
390402
Returns
391403
-------
392404
out : StreamplotSet
393405
394-
Other parameters
406+
Other Parameters
395407
----------------
396408
rcParams : dict
397409
Override the default parameters used for generating plots.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy