Plot point markers and lines in different hues but the same style with seaborn.lineplot
See original GitHub issueVersion information:
pandas
: 0.23.4seaborn
: 0.9.0matplotlib
: 2.2.3
Given the dataset and matplotlib backend below:
import pandas as pd
import seaborn as sns
%matplotlib notebook
sns.set()
df = pd.DataFrame({
"n_index": list(range(5)) * 2,
"logic": [True] * 5 + [False] * 5,
"value": list(range(5)) + list(range(5, 10))
})
Does not generate markers at all:
sns.lineplot(x="n_index", y="value", hue="logic", markers=True, data=df)
Generates markers but the lines or points are in different styles:
sns.lineplot(x="n_index", y="value", hue="logic", style="logic", markers=True, data=df)
sns.lineplot(x="n_index", y="value", hue="logic", style="logic", markers=["o", "o"], data=df)
Generates markers as desired but the legend ignores what is drown by the artist:
sns.lineplot(x="n_index", y="value", hue="logic", marker="o", data=df)
In sum, the markers
parameter in seaborn.lineplot
cannot generate markers in different hues when keeping other elements in the same style, which suggests that two aesthetic dimensions are needed on one data dimension in this use case. I believe that violates the principles of aesthetic mapping. On the other hand, using marker
parameter from matplotlib
generates the lines and points as expected, but the legend does not have any marker.
Given the rationale above, I think this is either a needed new feature or a bug need fixing. For more detailed discussion, please visit the question I raised on StackOverflow: Plot point markers and lines in different hues but the same style with seaborn.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Then perhaps you should have accepted the answer that does …
I saw the StackOverflow question. You got several good answers there. This isn’t a bug.