diff options
author | Daniel Friesel <derf@finalrewind.org> | 2019-02-05 07:58:27 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2019-02-05 07:58:27 +0100 |
commit | 5be7d04a725d3416acba6b11478d7075ada860ea (patch) | |
tree | 794e574d43b8d858b45ad9a022ff11fa11ef028d /lib/plotter.py | |
parent | 54ae64d2c6cd4247d84ddd010dd7052213759496 (diff) |
plotter: Add generic plot_attribute function for by_* boxplots
Diffstat (limited to 'lib/plotter.py')
-rwxr-xr-x | lib/plotter.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/plotter.py b/lib/plotter.py index 24e2197..9ba4786 100755 --- a/lib/plotter.py +++ b/lib/plotter.py @@ -75,6 +75,22 @@ def plot_states_param(model, aggregate): mdata = [int(model['state'][key[0]]['power']['static']) for key in keys] boxplot(keys, mdata, None, data, 'Transition', 'µW') +def plot_attribute(aggregate, attribute, attribute_unit = '', key_filter = lambda x: True): + """ + Boxplot measurements of a single attribute according to the partitioning provided by aggregate. + + Plots aggregate[*][attribute] with one column per aggregate key. + + arguments: + aggregate -- measurements. aggregate[*][attribute] must be list of numbers + attribute -- attribute to plot, e.g. 'power' or 'duration' + attribute_init -- attribute unit for display in X axis legend + key_filter -- if set: Only plot keys where key_filter(key) returns True + """ + keys = list(filter(key_filter, sorted(aggregate.keys()))) + data = [aggregate[key][attribute] for key in keys] + boxplot(keys, None, None, data, attribute, attribute_unit) + def plot_substate_thresholds_p(model, aggregate): keys = [key for key in sorted(aggregate.keys()) if aggregate[key]['isa'] == 'state' and key[0] != 'UNINITIALIZED'] data = [aggregate[key]['sub_thresholds'] for key in keys] |