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
When using thefill_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()
Actual outcome
Expected outcome
Additional information
No response
Operating system
Windows 11
Matplotlib Version
3.8.0
Matplotlib Backend
module://backend_interagg
Python version
Python 3.11.5
Jupyter version
No response
Installation
conda