From 36687acf5c4f76fcd3c696eed9eb77e31a801b99 Mon Sep 17 00:00:00 2001
From: Holden Rohrer
Date: Sun, 10 Jan 2021 21:36:48 -0500
Subject: finished graphs (mostly)
---
Makefile | 14 +++++++++++---
py/boxplot.py | 2 +-
py/lineplot.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 58 insertions(+), 4 deletions(-)
create mode 100644 py/lineplot.py
diff --git a/Makefile b/Makefile
index 47a2e33..0905900 100644
--- a/Makefile
+++ b/Makefile
@@ -60,13 +60,21 @@ graph/dir:
mkdir -p graph
touch graph/dir
-graph/made: graph/depth_width.png graph/nearest_neighbor.png graph/dir
+graph/made: graph/depth_width.png graph/nearest_neighbor.png graph/dir \
+graph/lineplot.png graph/boxplot.png
touch graph/made
graph/depth_width.png: py/data.py py/depwid.py graph/dir
$(PY) py/depwid.py
- mv depth_width.png graph
+ mv depth_width.png graph/
graph/nearest_neighbor.png: py/data.py py/neighbor.py graph/dir
$(PY) py/neighbor.py
- mv nearest_neighbor.png graph
+ mv nearest_neighbor.png graph/
+
+graph/lineplot.png: py/data2.py py/lineplot.py graph/dir
+ $(PY) py/boxplot.py
+ mv boxplot.png graph/
+
+graph/lineplot.png: py/data2.py py/boxplot.py graph/dir
+ mv lineplot.png graph/
diff --git a/py/boxplot.py b/py/boxplot.py
index 7d2cf1e..be1c024 100644
--- a/py/boxplot.py
+++ b/py/boxplot.py
@@ -10,4 +10,4 @@ for trial in trials:
plt.boxplot(vecs, labels=names)
plt.title('Nearest Neighbor for Each Pit in Different Trials')
plt.ylabel('Distance to Nearest Neighbor (cm)')
-plt.show()
+plt.savefig('boxplot.png', bbox_inches='tight')
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')
--
cgit