I'm trying to plot a graph and keep getting the error ValueError: not enough values to unpack (expected 2, got 1)
#turning csv into array
``AL_Force=data1["Force (kN)"].to_numpy()
`Al_Strain_p=data1["Tensile strain (Strain 1)(%)"] #strain in %
``#Calculating Stress=Force/Area
AL_stress=AL_Force/AL_a
#changing strain % into a fraction
AL_Strain=Al_Strain_p/100
#High Carbon Steel data#
#turning csv into an array
HC_Force=data3["Force(kN)"].to_numpy()
HC_Strain_p=data3["Tensile strain (Strain 1)(%)"].to_numpy()
#calcuting stress
HC_Stress=HC_Force/HC_a
#changing strain % into a fraction
HC_Strain=HC_Strain_p/100
#Low Carbon Steel Data#
LC_Force=data2["Force(kN)"].to_numpy()
LC_Strain_p=data2["Tensile strain (Strain 1)(%)"]
#calculating stress
LC_Stress=LC_Force/LC_a
#changing strain % into a fraction
LC_Strain=LC_Strain_p/100
#plotting graph
fig,ax1=plt.plot(AL_stress,AL_Strain,linestyle='-',color='black')
Your issue is your final line. plt.plot() returns a single object but you are setting it to two variables: fig
and ax1
. Change to:
fig = plt.plot(AL_stress, AL_Strain, linestyle='-',color='black')
If you want to investigate how subplots (why you would use ax) are used check out this other answer .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.