Skip to content

Allow time_response_plot to plot a list of responses - #1254

Closed
raashish1601 wants to merge 1 commit into
python-control:mainfrom
raashish1601:fix/1171-time-response-plot-list
Closed

raashish1601 wants to merge 1 commit into
python-control:mainfrom
raashish1601:fix/1171-time-response-plot-list

Conversation

@raashish1601

Copy link
Copy Markdown

Fixes #1171.

time_response_plot() failed when given a list of responses, as in the issue:

resp1 = ct.input_output_response(sys, timepts, np.sin(timepts))
resp2 = ct.input_output_response(sys, timepts, np.cos(timepts))
ct.time_response_plot([resp1, resp2])  # AttributeError: 'list' object has no attribute 'plot_inputs'

A list (or tuple) is now handed to TimeResponseList.plot(), which plots the responses one after the other on the same axes, so the result is the same as resp1.plot(); resp2.plot() (the plot the issue describes as the desired one) and as ct.TimeResponseList([resp1, resp2]).plot(). All keyword arguments, *fmt and a list of labels are passed through. I did not change the color scheme discussed at the end of the issue; the colors are the same as with TimeResponseList.plot() today.

Added test_time_response_plot_list to control/tests/timeplot_test.py (the example from the issue with plot_inputs None, True, 'overlay' and False, compared line by line with TimeResponseList.plot()). It fails on main and passes here. timeplot_test.py, timeresp_test.py, ctrlplot_test.py, kwargs_test.py and docstrings_test.py pass locally (542 passed, 51 skipped), and ruff check is clean.

@slivingston

Copy link
Copy Markdown
Member

@raashish1601 Can you disclose if and how you used AI tools to do this work? (Please read the README section about contributing and in particular https://numpy.org/doc/stable/dev/ai_policy.html.)

@raashish1601

Copy link
Copy Markdown
Author

Closing, see #1255 (comment) and the reply below it: this was prepared with an AI coding agent, which the NumPy AI policy referenced in your README does not allow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug in time_response_plot for multiple responses + improvements in input/output colors.

2 participants