-
Notifications
You must be signed in to change notification settings - Fork 411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Time response plots #920
Merged
Merged
Time response plots #920
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 tasks
murrayrm
force-pushed
the
time_plots-20Jun2023
branch
from
July 10, 2023 04:37
0a2d3c0
to
bab5071
Compare
Looks pretty comprehensive and pretty good to me. I particuarly like that this makes it much quicker to plot the inputs and outputs of a mimo system. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements time response plots for the various simulation routines in python-control via a new function
time_response_plot()
and via theplot()
method on theTimeResponseData
class. This is aligned with the new plotting paradigm in #645.Examples (from the user documentation):
Input/output time responses are produced using one of several python-control functions:
forced_response
,impulse_response
,initial_response()
,input_output_response()
, andstep_response()
. Each of these return aTimeResponseData
object, which contains the time, input, state, and output vectors associated with the simulation. Time response data can be plotted with thetime_response_plot()
function, which is also available as theplot()
method. For example, the step response for a two-input, two-output can be plotted using the commands:which produces the following plot:
The
TimeResponseData
object can also be used to access the data from the simulation:A number of options are available in the plot method to customize the appearance of input output data. For data produced by the
impulse_response()
andstep_response()
commands, the inputs are not shown. This behavior can be changed using theplot_inputs
keyword. It is also possible to combine multiple lines onto a single graph, using either theoverlay_signals
keyword (which puts all outputs out a single graph and all inputs on a single graph) or theoverlay_traces
keyword, which puts different traces (e.g., corresponding to step inputs in different channels) on the same graph, with appropriate labeling via a legend on selected axes.For example, using
plot_input=True
andoverlay_signals=True
yields the following plot:Input/output response plots created with either the
forced_response()
or theinput_output_response()
functions include the input signals by default. These can be plotted on separate axes, but also “overlaid” on the output axes (useful when the input and output signals are being compared to each other). The following plot shows the use ofplot_inputs=’overlay’
as well as the ability to reposition the legends using thelegend_map
keyword:Another option that is available is to use the transpose keyword so that instead of plotting the outputs on the top and inputs on the bottom, the inputs are plotted on the left and outputs on the right, as shown in the following figure:
This figure also illustrates the ability to create “multi-trace” plots using the
combine_traces()
function.Additional customization is possible using the
input_props
,output_props
andtrace_props
keywords to set complementary line colors and styles for various signals and traces: