@@ -48,7 +48,6 @@ def time_response_plot(
48
48
data , * fmt , ax = None , plot_inputs = None , plot_outputs = True ,
49
49
transpose = False , overlay_traces = False , overlay_signals = False ,
50
50
legend_map = None , legend_loc = None , add_initial_zero = True ,
51
- input_props = None , output_props = None , trace_props = None ,
52
51
trace_labels = None , title = None , relabel = True , ** kwargs ):
53
52
"""Plot the time response of an input/output system.
54
53
@@ -162,19 +161,19 @@ def time_response_plot(
162
161
time_label = config ._get_param (
163
162
'timeplot' , 'time_label' , kwargs , _timeplot_defaults , pop = True )
164
163
165
- if input_props and len (fmt ) > 0 :
164
+ if kwargs . get ( ' input_props' , None ) and len (fmt ) > 0 :
166
165
warn ("input_props ignored since fmt string was present" )
167
166
input_props = config ._get_param (
168
167
'timeplot' , 'input_props' , kwargs , _timeplot_defaults , pop = True )
169
168
iprop_len = len (input_props )
170
169
171
- if output_props and len (fmt ) > 0 :
170
+ if kwargs . get ( ' output_props' , None ) and len (fmt ) > 0 :
172
171
warn ("output_props ignored since fmt string was present" )
173
172
output_props = config ._get_param (
174
173
'timeplot' , 'output_props' , kwargs , _timeplot_defaults , pop = True )
175
174
oprop_len = len (output_props )
176
175
177
- if trace_props and len (fmt ) > 0 :
176
+ if kwargs . get ( ' trace_props' , None ) and len (fmt ) > 0 :
178
177
warn ("trace_props ignored since fmt string was present" )
179
178
trace_props = config ._get_param (
180
179
'timeplot' , 'trace_props' , kwargs , _timeplot_defaults , pop = True )
@@ -306,35 +305,33 @@ def time_response_plot(
306
305
# Map inputs/outputs and traces to axes
307
306
#
308
307
# This set of code takes care of all of the various options for how to
309
- # plot the data. The arrays ax_outputs and ax_inputs are used to map
308
+ # plot the data. The arrays output_map and input_map are used to map
310
309
# the different signals that are plotted onto the axes created above.
311
310
# This code is complicated because it has to handle lots of different
312
311
# variations.
313
312
#
314
313
315
314
# Create the map from trace, signal to axes, accounting for overlay_*
316
- ax_outputs = np .empty ((noutputs , ntraces ), dtype = object )
317
- ax_inputs = np .empty ((ninputs , ntraces ), dtype = object )
315
+ output_map = np .empty ((noutputs , ntraces ), dtype = tuple )
316
+ input_map = np .empty ((ninputs , ntraces ), dtype = tuple )
318
317
319
318
for i in range (noutputs ):
320
319
for j in range (ntraces ):
321
320
signal_index = i if not overlay_signals else 0
322
321
trace_index = j if not overlay_traces else 0
323
322
if transpose :
324
- ax_outputs [i , j ] = \
325
- ax_array [trace_index , signal_index + ninput_axes ]
323
+ output_map [i , j ] = (trace_index , signal_index + ninput_axes )
326
324
else :
327
- ax_outputs [i , j ] = ax_array [ signal_index , trace_index ]
325
+ output_map [i , j ] = ( signal_index , trace_index )
328
326
329
327
for i in range (ninputs ):
330
328
for j in range (ntraces ):
331
329
signal_index = noutput_axes + (i if not overlay_signals else 0 )
332
330
trace_index = j if not overlay_traces else 0
333
331
if transpose :
334
- ax_inputs [i , j ] = \
335
- ax_array [trace_index , signal_index - noutput_axes ]
332
+ input_map [i , j ] = (trace_index , signal_index - noutput_axes )
336
333
else :
337
- ax_inputs [i , j ] = ax_array [ signal_index , trace_index ]
334
+ input_map [i , j ] = ( signal_index , trace_index )
338
335
339
336
#
340
337
# Plot the data
@@ -361,7 +358,10 @@ def time_response_plot(
361
358
inputs = data .u .reshape (data .ninputs , ntraces , - 1 )
362
359
363
360
# Create a list of lines for the output
364
- out = np .empty ((noutputs + ninputs , ntraces ), dtype = object )
361
+ out = np .empty ((nrows , ncols ), dtype = object )
362
+ for i in range (nrows ):
363
+ for j in range (ncols ):
364
+ out [i , j ] = [] # unique list in each element
365
365
366
366
# Utility function for creating line label
367
367
def _make_line_label (signal_index , signal_labels , trace_index ):
@@ -402,7 +402,7 @@ def _make_line_label(signal_index, signal_labels, trace_index):
402
402
else :
403
403
line_props = kwargs
404
404
405
- out [i , trace ] = ax_outputs [ i , trace ].plot (
405
+ out [output_map [ i , trace ]] += ax_array [ output_map [ i , trace ] ].plot (
406
406
data .time , outputs [i ][trace ], * fmt , label = label , ** line_props )
407
407
408
408
# Plot the input
@@ -425,7 +425,7 @@ def _make_line_label(signal_index, signal_labels, trace_index):
425
425
else :
426
426
line_props = kwargs
427
427
428
- out [noutputs + i , trace ] = ax_inputs [ i , trace ].plot (
428
+ out [input_map [ i , trace ]] += ax_array [ input_map [ i , trace ] ].plot (
429
429
x , y , * fmt , label = label , ** line_props )
430
430
431
431
# Stop here if the user wants to control everything
@@ -457,23 +457,23 @@ def _make_line_label(signal_index, signal_labels, trace_index):
457
457
if overlay_signals and plot_inputs :
458
458
label = overlaid_title if overlaid else "Inputs"
459
459
for trace in range (ntraces ):
460
- ax_inputs [ 0 , trace ].set_ylabel (label )
460
+ ax_array [ input_map [ 0 , trace ] ].set_ylabel (label )
461
461
else :
462
462
for i in range (ninputs ):
463
463
label = overlaid_title if overlaid else data .input_labels [i ]
464
464
for trace in range (ntraces ):
465
- ax_inputs [ i , trace ].set_ylabel (label )
465
+ ax_array [ input_map [ i , trace ] ].set_ylabel (label )
466
466
467
467
# Label the outputs
468
468
if overlay_signals and plot_outputs :
469
469
label = overlaid_title if overlaid else "Outputs"
470
470
for trace in range (ntraces ):
471
- ax_outputs [ 0 , trace ].set_ylabel (label )
471
+ ax_array [ output_map [ 0 , trace ] ].set_ylabel (label )
472
472
else :
473
473
for i in range (noutputs ):
474
474
label = overlaid_title if overlaid else data .output_labels [i ]
475
475
for trace in range (ntraces ):
476
- ax_outputs [ i , trace ].set_ylabel (label )
476
+ ax_array [ output_map [ i , trace ] ].set_ylabel (label )
477
477
478
478
# Set the trace titles, if needed
479
479
if ntraces > 1 and not overlay_traces :
@@ -507,20 +507,20 @@ def _make_line_label(signal_index, signal_labels, trace_index):
507
507
508
508
# Label the outputs
509
509
if overlay_signals and plot_outputs :
510
- ax_outputs [ 0 , 0 ].set_ylabel ("Outputs" )
510
+ ax_array [ output_map [ 0 , 0 ] ].set_ylabel ("Outputs" )
511
511
else :
512
512
for i in range (noutputs ):
513
- ax_outputs [ i , 0 ].set_ylabel (
513
+ ax_array [ output_map [ i , 0 ] ].set_ylabel (
514
514
overlaid_title if overlaid else data .output_labels [i ])
515
515
516
516
# Label the inputs
517
517
if overlay_signals and plot_inputs :
518
518
label = overlaid_title if overlaid else "Inputs"
519
- ax_inputs [ 0 , 0 ].set_ylabel (label )
519
+ ax_array [ input_map [ 0 , 0 ] ].set_ylabel (label )
520
520
else :
521
521
for i in range (ninputs ):
522
522
label = overlaid_title if overlaid else data .input_labels [i ]
523
- ax_inputs [ i , 0 ].set_ylabel (label )
523
+ ax_array [ input_map [ i , 0 ] ].set_ylabel (label )
524
524
525
525
#
526
526
# Create legends
0 commit comments