In [1]:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline

In [2]:
# read in the data
df=pd.read_csv('data.csv', sep=',',header=None,skiprows=1)
delta_L = np.array(df[1])*1000  
force = np.array(df[2])

# sample parameters
d = 1.778     # diameter of sample in mm
A0 = np.pi*(d/2)**2 # original cross-sectional area of sample in mm^2
L0 = 18.002   # original gauge length of sample (lenth of narrowest section)

# calcuate stress and strain
stress = (force/A0)
strain = delta_L/L0

# plot the stress strain curve
plt.plot(strain,stress)
plt.xlabel('Strain (mm/mm)')
plt.ylabel('Stress (MPa)')
plt.title('Stress-Strain Curve of Al6061 - T6')
plt.axis([0, 1.4, 0, 60])
plt.grid(True)

# inset axes overlayed on the main axes
#a = plt.axes([0.2, 0.2, .3, .3], facecolor='w')
#plt.plot(strain, stress)
#plt.title('Inset of Elastic Region')
#plt.xlim(0, 0.05)
#plt.ylim(0, 40)


plt.savefig('stress_strain_no_inset.png',dpi=72)
plt.show()



In [ ]: