Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Closed
Labels
Milestone
Description
Bug summary
The color of the global legend for all subplots does not match the label colors.
Code for reproduction
esbs=np.array(list(range(0,41)))lines= [eforeinasrs]colors= ['dodgerblue','tomato','yellowgreen','orange','dodgerblue','tomato','yellowgreen','orange']labels= ['A','C','M','F','A+','C+','M+','F+',]linestyles= ['-','-','-','-','--','--','--','--']fig,axs=plt.subplots(2,figsize=(6,6),sharex=False)handles= []foriinrange(8):print(i,colors[i],labels[i])ifi==3ori==7:h=axs[1].plot(esbs,lines[i],color=colors[i],linewidth=1.2,linestyle=linestyles[i],label=labels[i])else:h=axs[0].plot(esbs,lines[i],color=colors[i],linewidth=1.2,linestyle=linestyles[i],label=labels[i])handles.append(h)fig.legend(handles,labels=labels,ncol=2,bbox_to_anchor=(0.15,1.06),loc='upper left')plt.show()
Actual outcome

Expected outcome
The colors for legend F and legend F+ should be orange. But they are different.
Additional information
No response
Operating system
No response
Matplotlib Version
3.7.1
Matplotlib Backend
No response
Python version
No response
Jupyter version
No response
Installation
None