-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Legend line is incorrect #3543
Comments
This is not a bug in any library, just a consequence of matplotlib’s “magic” legend creation not doing what you expect. When you call legend without providing explicit artists, it grabs the first two artists that are attached to the axes; in this case that happens to be the first line and its confidence interval because that is the order that seaborn adds things to the plot. I’m going to close because there is no action to be taken on the library side here and ample discussion of how to customize the legend in the docs and on eg stackoverflow. |
Thanks. I brought this up actually as I had experienced it when I updated pandas so it was sudden unexpected behavior. Reverting pandas caused the lines to be drawn correctly |
The point is that the specific ordering of artists in the matplotlib artist list is an implementation detail, so it’s risky to rely on it, as you do when calling legend() without a list of artist handles. I really wish this “feature” didn’t exist in matplotlib — it’s convenient for interactive, direct use of matplotlib, but it makes it too easy to get incorrect results (which may or may not be noticeable as they are here). I personally really urge you not to use it. But there’s not much seaborn can do about that. |
Hello, so I am not sure where to post specifically. This is a bug as of Pandas 2.0.0 I believe, and is when Matplotlib plt legend is called on what I've tested so far being the relplot alone.
pandas = 2.1.2
![image](https://private-user-images.githubusercontent.com/105056217/280003010-9bae593b-d01e-4dfa-b7d6-381ab927b029.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjEzMzA1MDMsIm5iZiI6MTcyMTMzMDIwMywicGF0aCI6Ii8xMDUwNTYyMTcvMjgwMDAzMDEwLTliYWU1OTNiLWQwMWUtNGRmYS1iN2Q2LTM4MWFiOTI3YjAyOS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNzE4JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDcxOFQxOTE2NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1mNzA2OGMyYTk3NzU2NjFjODZkYjRjOTc3ZDU5MGFiMGNkZGE3NmEyMDIzN2RkYTg4NDIyODdlYjU2MDc3NDg3JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.ypa0ZQMCRyVfqskiDRFCgTf_-radf1cUszWMEY1Z6r8)
matplotlib= 3.8.1
seaborn=0.13
The text was updated successfully, but these errors were encountered: