Contents
import matplotlib.pyplot as plt
import numpy as np

xs = np.linspace(0, np.pi, 50)

fig, ax = plt.subplots()

ys = 0
lbl=''

for n in [1, 3, 5]:
    a = 1.0/n

    ys = ys+a*np.sin(n*xs)

    lbl = lbl + f"1/{n} sin({n}x)"    
    
    ax.plot(xs, ys, label=lbl)

    lbl = lbl + '+' #why do we add the "+" at this point?

# set the legend and show the figure
ax.legend(loc=(1.01, 0))
fig.show()