aboutsummaryrefslogtreecommitdiff
path: root/python/depwid.py
diff options
context:
space:
mode:
authorHolden Rohrer <hr@hrhr.dev>2020-02-07 00:14:10 -0500
committerHolden Rohrer <hr@hrhr.dev>2020-02-07 00:14:10 -0500
commit230eafed9aefda8688c8b9269e600b7289326a52 (patch)
tree035c5e44c2400e0d214293a7fba86eb086f2b059 /python/depwid.py
parente3675ef3e0eda98482afc093b15fccb5b643a040 (diff)
cleaned up python directory structure
Diffstat (limited to 'python/depwid.py')
-rw-r--r--python/depwid.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/python/depwid.py b/python/depwid.py
new file mode 100644
index 0000000..081167f
--- /dev/null
+++ b/python/depwid.py
@@ -0,0 +1,22 @@
+from data import trials
+from math import sqrt
+from scipy.stats import pearsonr
+from collections import Counter
+import matplotlib.pyplot as plt
+
+depths, widths, sizes = [], [], []
+for trial in trials:
+ size = sqrt(trial.size[0]*trial.size[1])
+ for pit in trial.pits:
+ sizes.append(size)
+ depths.append(pit.depth)
+ widths.append(pit.diam)
+weights = [20*i for i in Counter(depths).values() for j in range(i)]
+plt.scatter([size-.5 for size in sizes], depths, weights, 'b','o', label='depth')
+weights = [20*i for i in Counter(widths).values() for j in range(i)]
+plt.scatter(sizes, widths, weights, 'r', 'o', label='width')
+plt.xlabel('Square root of Trial Area (cm)')
+plt.ylabel('Depth/Width of Antlion Pits (cm)')
+plt.legend(loc='upper right')
+plt.text(10, 7, 'R^2 = %.3f\np=%.3f' % (pearsonr(sizes,depths)[0], pearsonr(sizes,depths)[1]), ha='center', va='center')
+plt.savefig('depth_width.png', bbox_inches='tight')