question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

''move_legend'' lost the markers for lineplot and hatch for barplot

See original GitHub issue

Hi there,

The move_legend indeed makes the DIY legend much more convenient and saves me a lot of effort, however, I have two small issues that bothered me a lot.

Here is my code.

g=sns.catplot(x="X",  y="Y", data=data_df, kind="bar", legend=True, facet_kws={"legend_out": False})
sns.move_legend(g, "center", bbox_to_anchor=(.5, 0.05), ncol=3, title=None, frameon=False, numpoints=2)
g.fig.subplots_adjust(bottom=0.25)

image image

Would appreciate it if you could give me some hints.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mwaskomcommented, Jan 22, 2022

A reproducible example for the line plot is as follows.

What is self? In any case, after editing your code so that I can run it, I am unable to reproduce the issue as I understand it:

image

For the bar plot, are you expecting the legend to show the patches you are manually adding to the bars? They are not in the legend to begin with so you’d need to modify the legend artists too.

I found an extra issue in bar plot, the blank space was not automatically removed.

catplot has the legend_out parameter as part of its signature and i guess that overrides what appears in facet_kws.

0reactions
Milkigitcommented, Jan 22, 2022

Thanks for the update. Interestingly, directly modifying the legend artists of relplot also works for me. The workaround for the barplot blank is adjusting the subplots, which also solved my problem. 😂

g.fig.subplots_adjust(bottom=0.25, right=1)
Read more comments on GitHub >

github_iconTop Results From Across the Web

seaborn lineplot: marker symbols missing on legend
Solution 1: Here the markers appear in the legend twice for each series. Code: import seaborn as sns fmri = sns.load_dataset("fmri") ax=sns.
Read more >
Lines, bars and markers — Matplotlib 3.6.2 documentation
Hatch -filled histograms. Bar chart with gradients ... Discrete distribution as horizontal bar chart ... Mapping marker properties to multivariate data.
Read more >
seaborn.lineplot — seaborn 0.12.1 documentation - PyData |
Grouping variable that will produce lines with different dashes and/or markers. Can have a numeric dtype but will always be treated as categorical....
Read more >
Overlaying a line plot and a bar plot
A combination that is frequently seen is the overlay of a bar/column chart and a line chart. A typical example of this is...
Read more >
“get from dictionary but if key doesn't exist then default” ...
If it is a script, you may be missing a '#! ... render_template not showing images · how to add numbers on top...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found