%pylab inline %cat ../data/BrachiopodBiometrics.csv import numpy as np # Read in the records. record = np.recfromcsv("../data/BrachiopodBiometrics.csv") print record.dtype.names # Convert this to numpy arrays. lengthmm = np.array(record["lengthmm"], dtype=float) widthmm = np.array(record["widthmm"], dtype=float) print lengthmm print widthmm plot(lengthmm, widthmm, 'bx', markersize=5, markeredgewidth=2, zorder=3) # 'bx' - blue 'x' markers, 10 points in size, # drawn in a thickish line. # zorder=3 to make sure this is in front of grid from scipy import stats slope, intercept, r_value, p_value, std_err = stats.linregress(lengthmm, widthmm) x = np.array([lengthmm.min(), widthmm.max()]) y = slope*x+intercept plot(x,y) print "r and p values of linear regression: ", r_value, p_value # Not labeling a graph is unforgivable. This is the minimum that should be in any graph. ylabel("Length/mm",weight='bold') xlabel("Width/mm",weight='bold') title("Brachiopod Biometric data",weight='bold') show()