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.

Plot point markers and lines in different hues but the same style with seaborn.lineplot

See original GitHub issue

Version information:

  • pandas: 0.23.4
  • seaborn: 0.9.0
  • matplotlib: 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:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mwaskomcommented, Sep 19, 2018

You said you saw the StackOverflow question, then you should have noticed that the accepted answer was not able to plot the desired output with seaborn

Then perhaps you should have accepted the answer that does …

1reaction
mwaskomcommented, Sep 19, 2018

I saw the StackOverflow question. You got several good answers there. This isn’t a bug.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Plot point markers and lines in different hues but the same ...
Plot point markers and lines in different hues but the same style with seaborn ; import pandas as ; import seaborn as ;...
Read more >
seaborn.lineplot — seaborn 0.12.1 documentation - PyData |
Draw a line plot with possibility of several semantic groupings. The relationship between x and y can be shown for different subsets of...
Read more >
Seaborn lineplot (Visualize Data With Lines) - Like Geeks
You'll learn about Seaborn lineplot and how to visualize data in lines, plot multiple lines, change plot properties such as line style, ...
Read more >
Seaborn Line Plots: A Detailed Guide with Examples (Multiple ...
A detailed guide to Seaborn line plots, including plotting multiple lines, & a downloadable Jupyter Notebook with all code examples.
Read more >
Seaborn Line Plot Data Visualization - wellsr.com
This tutorial explains how to draw different line plots using the Python Seaborn library. It includes examples for setting line plot labels, ...
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