0

I'm new to matplotlib and I am making a graph that is meant to show two sets of runs in a simulation, each set of runs have 20 lines to be plotted. I want each set of lines to have one label shared by them but I can't find anything on how to do that.

df = pandas.read_csv(url)

parameq1 = np.array_split(df.loc[(df['param'] == 1) & (df['metric'] == 'noise')],20)
parameq2 = np.array_split(df.loc[(df['param'] == 2) & (df['metric'] == 'noise')],20)

time = np.arange(100) + 5000

fig, axes = plt.subplots()
for i in range(20):
    line = plt.plot(time,parameq1[i]['value'],color='lightgreen',alpha=0.7,label="param=1")

for i in range(20):
    plt.plot(time,parameq2[i]['value'],color='orange',alpha=0.6,label='param=2')
    
plt.show()

But here it shows 20 different legends rather than just one, surely there is an easy way to have the same legends for multiple plots?

fltray10
  • 31
  • 6
  • 1
    Does this answer your question? [pyplot combine multiple line labels in legend](https://stackoverflow.com/questions/26337493/pyplot-combine-multiple-line-labels-in-legend) – Antoine Dubuis Dec 06 '22 at 11:06

0 Answers0