I am doing a series of plots inside a for loop:
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0,1, 100)
y = np.sin(x)
for i in range(1,6):
plt.plot(x, i*y, label=f't= {i}')
plt.plot(x[::2], i*y[::2], marker='o', linestyle='None', markersize=2,label=f'a= {i}')
plt.legend(loc='best', ncol=2)
The output is:
I would like the legend to be:
How can I access the legend and make it like in the image above?


