summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2019-02-05 07:58:27 +0100
committerDaniel Friesel <derf@finalrewind.org>2019-02-05 07:58:27 +0100
commit5be7d04a725d3416acba6b11478d7075ada860ea (patch)
tree794e574d43b8d858b45ad9a022ff11fa11ef028d
parent54ae64d2c6cd4247d84ddd010dd7052213759496 (diff)
plotter: Add generic plot_attribute function for by_* boxplots
-rwxr-xr-xlib/plotter.py16
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]