-1

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')
BigBen
  • 46,229
  • 7
  • 24
  • 40
  • Please trim your code to make it easier to find your problem. Follow these guidelines to create a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example). – Community Jul 21 '22 at 16:44

1 Answers1

0

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.

  • Also worth noting that [plt.plot](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.plot.html) does not return a figure, so `fig` is rather misleading. – BigBen Jul 21 '22 at 16:15