Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Bug]: Legend overlaps shaded area in fill_between with legend location "best" #27414

Closed
Milestone
@mauroo4

Description

@mauroo4

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

image

Expected outcome

image

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp