You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the fill_between function in matplotlib with a legend and specifying the legend location as "best", the legend is not taking into account the shaded area and may overlap with it.
Code for reproduction
importmatplotlib.pyplotaspltimportnumpyasnp# Example datax=np.linspace(0, 5, 100)
y1=0.5*np.exp(x) -1y2=2*np.exp(x) +1# Plotting shaded areaplt.fill_between(x, y1, y2, color='gray', alpha=0.5, label='Shaded Area')
# Set y-axis limitplt.ylim(-10, 100)
# Adding legend with location "best"plt.legend(loc='best')
# Show the plotplt.show()