diff options
author | Holden Rohrer <hr@hrhr.dev> | 2020-01-12 00:37:38 -0500 |
---|---|---|
committer | Holden Rohrer <hr@hrhr.dev> | 2020-01-12 00:37:38 -0500 |
commit | c97bdb5a5369557477984b1ac321465697dfdf7d (patch) | |
tree | c8d87ad63c585a13821ce3a49a80f0ea199f361d | |
parent | 3459faf6594a610d577955a28cd4035285a90fff (diff) |
data now has p-values
-rw-r--r-- | data.py | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -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)') |