aboutsummaryrefslogtreecommitdiff
path: root/data.py
diff options
context:
space:
mode:
Diffstat (limited to 'data.py')
-rw-r--r--data.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/data.py b/data.py
index 9acbdbb..f345b1e 100644
--- a/data.py
+++ b/data.py
@@ -129,24 +129,29 @@ elif arg == 'nei':
#y += nei
x.append(size)
y.append(sum(nei)/len(nei))
- print('p-value', pearsonr(x,y))
+ fig = plt.figure()
+ ax = fig.add_subplot(111)
+ plt.text(0.1, 0.9, 'R^2 = %.3f\np=%.3f' % (pearsonr(x,y)[0]**2, pearsonr(x,y)[1]), ha='center', va='center', transform=ax.transAxes)
plt.xlabel('Square root of Trial Area (cm)')
plt.ylabel('Nearest Neighbor for Individual Pits (cm)')
plt.plot(x, y, 'bo')
plt.plot(x, np.poly1d(np.polyfit(x, y, 1))(x))
plt.savefig('nearest_neighbor.png', bbox_inches='tight')
elif arg == 'depwid':
- depths, widths = [], []
+ depths, widths, sizes = [], [], []
for trial in trials:
size = math.sqrt(trial.size[0]*trial.size[1])
for pit in trial.pits:
- depths.append((size,pit.depth))
- widths.append((size,pit.diam))
- plt.plot([depth[0] for depth in depths], [depth[1] for depth in depths], 'bo', label='depth')
- plt.plot([width[0] for width in widths], [width[1] for width in widths], 'ro', label='width')
+ sizes.append(size)
+ depths.append(pit.depth)
+ widths.append(pit.diam)
+ print(sizes, depths, widths)
+ plt.plot([size-.5 for size in sizes], depths, 'bo', label='depth')
+ plt.plot(sizes, widths, 'ro', 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')
if arg == 'table':
print('Dimensions (in)\tPit Depth (cm)\tPit Width (cm)\tNearest Neighbor (cm)')