数字格式python

I want to have the legend of the plot shown with the value in a list. But what I get is the element index but not the value itself. I dont know how to fix it. I'm referring to the plt.plot line. Thanks for the help.

epsilon = np.linspace(0.01,1,num=10)
sigma = np.linspace(0.01,1,num=10)

def lj_pot(epsi,sig,d):
    result = []
    for i in range(len(d)):
        a = 4*epsi*((sig/d[i])**12-(sig/d[i])**6)
        result.append(a)

    return result

for i in range(len(epsilon)):
    for j in range(len(sigma)):
        a = epsilon[i]
        b = sigma[j]
        plt.cla()
        plt.ylim([-1.5, 1.5])
        plt.xlim([0, 2])
        plt.plot(sorted(d_ij),lj_pot(epsilon[i],sigma[j],sorted(d_ij)),label = 'epsilon = %d, sigma =%d' %(a,b))
        plt.legend()
        plt.savefig("epsilon_%d_sigma_%d.png" % (i,j))


plt.show()

评论