GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Bug in time_response_plot for multiple responses + improvements in input/output colors. · Issue #1171 · python-control/python-control

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

New issue
Copy link
New issue
Copy link
Open
Open
Bug in time_response_plot for multiple responses + improvements in input/output colors.#1171
Copy link

Description

@murrayrm
murrayrm
opened on Jul 19, 2025
Issue body actions

The following code should work, but generates an error:

import numpy as np
import control as ct

sys = ct.ss(ct.tf([1, 2], [3, 4, 5]))
timepts = np.linspace(0, 10)
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])

Output:

File ~/Library/CloudStorage/Dropbox/macosx/src/python-control/murrayrm/control/timeplot.py:210, in time_response_plot(data, ax, plot_inputs, plot_outputs, transpose, overlay_traces, overlay_signals, add_initial_zero, label, trace_labels, title, relabel, *fmt, **kwargs)
    208 # Determine whether or not to plot the input data (and how)
    209 if plot_inputs is None:
--> 210     plot_inputs = data.plot_inputs
    211 if plot_inputs not in [True, False, 'overlay']:
    212     raise ValueError(f"unrecognized value: {plot_inputs=}")

AttributeError: 'list' object has no attribute 'plot_inputs'

Attempting to fixing the error manually, I tried:

ct.time_response_plot([resp1, resp2], plot_inputs=True)

which generated another error:

File ~/Library/CloudStorage/Dropbox/macosx/src/python-control/murrayrm/control/timeplot.py:266, in time_response_plot(data, ax, plot_inputs, plot_outputs, transpose, overlay_traces, overlay_signals, add_initial_zero, label, trace_labels, title, relabel, *fmt, **kwargs)
    212     raise ValueError(f"unrecognized value: {plot_inputs=}")
    214 #
    215 # Find/create axes
    216 #
   (...)
    264 
    265 # Decide on the number of inputs and outputs
--> 266 ninputs = data.ninputs if plot_inputs else 0
    267 noutputs = data.noutputs if plot_outputs else 0
    268 ntraces = max(1, data.ntraces)      # treat data.ntraces == 0 as 1 trace

AttributeError: 'list' object has no attribute 'ninputs'

Those should be fairly easy to fix. While doing so, it might be nice to think through the color and labeling scheme as well. Using the following commands generates the desired plot, but the labeling is confusing:

resp1.plot()
resp2.plot()
Image

What I would have expected here is that the colors of the traces in the top and bottom panels would be the same, so that you could figure out which went with which.

Of course, there are other situations for which one wants different colors in the inputs and outputs, for example for a MIMO system:

sys_mimo = ct.rss(4, 2, 2)
resp = ct.input_output_response(sys_mimo, timepts, [np.sin(timepts), np.cos(timepts)])
resp.plot(overlay_signal=True)

which generates

Image

Here the output and input traces all have different colors because there is no reason to associate output $i$ with input $i$ in a general MIMO system.

Activity

  1. huxiaoyi-ovo
    added a commit that references this issue on Oct 8, 2026

    Fix time_response_plot for lists of time responses (python-control#1171)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.