control.time_response_plot(data, *fmt, ax=None, plot_inputs=None, plot_outputs=True, transpose=False, overlay_traces=False, overlay_signals=False, legend_map=None, legend_loc=None, add_initial_zero=True, trace_labels=None, title=None, relabel=True, **kwargs)[source]

Plot the time response of an input/output system.

This function creates a standard set of plots for the input/output response of a system, with the data provided via a TimeResponseData object, which is the standard output for python-control simulation functions.

  • data (TimeResponseData) – Data to be plotted.

  • ax (array of Axes) – The matplotlib Axes to draw the figure on. If not specified, the Axes for the current figure are used or, if there is no current figure with the correct number and shape of Axes, a new figure is created. The default shape of the array should be (noutputs + ninputs, ntraces), but if overlay_traces is set to True then only one row is needed and if overlay_signals is set to True then only one or two columns are needed (depending on plot_inputs and plot_outputs).

  • plot_inputs (bool or str, optional) –

    Sets how and where to plot the inputs:
    • False: don’t plot the inputs

    • None: use value from time response data (default)

    • ’overlay`: plot inputs overlaid with outputs

    • True: plot the inputs on their own axes

  • plot_outputs (bool, optional) – If False, suppress plotting of the outputs.

  • overlay_traces (bool, optional) – If set to True, combine all traces onto a single row instead of plotting a separate row for each trace.

  • overlay_signals (bool, optional) – If set to True, combine all input and output signals onto a single plot (for each).

  • transpose (bool, optional) – If transpose is False (default), signals are plotted from top to bottom, starting with outputs (if plotted) and then inputs. Multi-trace plots are stacked horizontally. If transpose is True, signals are plotted from left to right, starting with the inputs (if plotted) and then the outputs. Multi-trace responses are stacked vertically.

  • *fmt (matplotlib.pyplot.plot() format string, optional) – Passed to matplotlib as the format string for all lines in the plot.

  • **kwargs (matplotlib.pyplot.plot() keyword properties, optional) – Additional keywords passed to matplotlib to specify line properties.

  • add_initial_zero (bool) – Add an initial point of zero at the first time point for all inputs with type ‘step’. Default is True.

  • input_props (array of dicts) – List of line properties to use when plotting combined inputs. The default values are set by config.defaults[‘timeplot.input_props’].

  • legend_map (array of str, option) – Location of the legend for multi-trace plots. Specifies an array of legend location strings matching the shape of the subplots, with each entry being either None (for no legend) or a legend location string (see legend()).

  • legend_loc (str) – Location of the legend within the axes for which it appears. This value is used if legend_map is None.

  • output_props (array of dicts) – List of line properties to use when plotting combined outputs. The default values are set by config.defaults[‘timeplot.output_props’].

  • relabel (bool, optional) – By default, existing figures and axes are relabeled when new data are added. If set to False, just plot new data on existing axes.

  • time_label (str, optional) – Label to use for the time axis.

  • trace_props (array of dicts) – List of line properties to use when plotting combined outputs. The default values are set by config.defaults[‘timeplot.trace_props’].


out – Array of Line2D objects for each line in the plot. The shape of the array matches the subplots shape and the value of the array is a list of Line2D objects in that subplot.

Return type

array of list of Line2D


  1. A new figure will be generated if there is no current figure or the current figure has an incompatible number of axes. To force the creation of a new figures, use plt.figure(). To reuse a portion of an existing figure, use the ax keyword.

  2. The line properties (color, linestyle, etc) can be set for the entire plot using the fmt and/or kwargs parameter, which are passed on to matplotlib. When combining signals or traces, the input_props, output_props, and trace_props parameters can be used to pass a list of dictionaries containing the line properties to use. These input/output properties are combined with the trace properties and finally the kwarg properties to determine the final line properties.

  3. The default plot properties, such as font sizes, can be set using config.defaults[‘’timeplot.rcParams’].