aboutsummaryrefslogtreecommitdiff
path: root/py/lineplot.py
diff options
context:
space:
mode:
Diffstat (limited to 'py/lineplot.py')
-rw-r--r--py/lineplot.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/py/lineplot.py b/py/lineplot.py
new file mode 100644
index 0000000..efe6b67
--- /dev/null
+++ b/py/lineplot.py
@@ -0,0 +1,46 @@
+from data2 import trials
+from statistics import stdev,mean
+import matplotlib.pyplot as plt
+from numpy import arange
+
+stderr = []
+avg = []
+deps = {'nn':[[],[]], 'wid':[[],[]], 'dep':[[],[]], 'recl':[[],[]],
+ 'dead':[[],[]]}
+varlist = tuple(deps.keys())
+title = {'nn':'Nearest Neighbor', 'wid':'Pit Width', 'dep':'Pit Depth',
+'recl':'Reclusive Population', 'dead':'Cannibalized Individuals'}
+names = []
+
+ct = 0
+
+def addvar(key, data):
+ deps[key][0].append(mean(data))
+ deps[key][1].append(stdev(data))
+
+for trial in trials:
+ names.append(str(trial))
+ addvar('nn',trial.nearest_neighbor())
+ addvar('wid',[pit.diam for pit in trial.pits])
+ addvar('dep',[pit.depth for pit in trial.pits])
+ addvar('recl',[trial.recl for pit in trial.pits])
+ addvar('dead',[trial.dead for pit in trial.pits])
+
+x = arange(len(names))
+
+width = 0.8;
+plt.yticks(x,labels=names)
+
+print(names,avg)
+#for var in varlist:
+stdscale = 1/2
+for ind in range(len(varlist)):
+ var = varlist[ind]
+ div = mean(deps[var][0])
+ plt.bar(x-ind*width/len(varlist), [dep/div for dep in deps[var][0]],
+ yerr=[stdscale*dep/div for dep in deps[var][1]], capsize=6,
+ label=title[var],alpha=0.5, width=width/len(varlist))
+ #plt.errorbar(names, [dep/div for dep in deps[var][0]],
+ #yerr=[dep/div/4 for dep in deps[var][1]], capsize=12, label=title[var], marker="o")
+plt.legend()
+plt.savefig('lineplot.png', bbox_inches='tight')