I have a repetitive label in legend. How can I fix that? and how can I assign each label to its specific curve? I also want to modify the curves themselves by changing the colors. line width and style
import numpy as np
import matplotlib.pyplot as plt
import math
from scipy.special import erfc
pdi = 0
TD=[0.05, 0.1, 1]
def Dirichlet_Dirichlet(td_arr = [ 0.05, 0.1, 1],
xd_arr = np.arange(0,1,0.001)):
for td in td_arr:
xd = xd_arr
sumBound = np.arange(1,100,1)
sumTerm1 = np.zeros(len(xd))
sumTerm2 = np.zeros(len(xd))
for n in sumBound:
sumTerm1 += (((-1)**n) / n)*np.sin(n*np.pi*xd)*np.exp(-(n**2)*(np.pi**2)* td)
sumTerm2 += (((-1)**n) / n)*np.sin(n*np.pi*(xd - 1))*np.exp(-(n**2)*(np.pi**2)* td)
res = 1 - xd - (2*pdi/np.pi)*sumTerm1 - (2*(1-pdi)/np.pi)*sumTerm2
for td in TD:
plt.plot(xd, res, label='$t_D$={}'.format(round(td,3)))
plt.xlabel("'$\\xi_D$'")
plt.ylabel("Dimensionless Pressure, $P_D$")
plt.legend()
plt.xlim(0, 1)
plt.ylim(0, 1)
plt.title('Plot Dimensionless Pressure vs. Distance: Dirichlet_Dirichlet')
plt.tight_layout()
plt.title('Analytical Solution')
plt.show()
Dirichlet_Dirichlet()