How to plot different line style for each column in the dataset using seaborn

Viewed 166

I have the following dataset df:

A   B   C   D   E
1   2   5   6   9  
7   9   10  11  13
6   10  11  23  87

I want to create a seaborn line plot so that for each of the columns I get a different linestyle with the same color, the linestyle which I can choose, however, I am clueless about how to proceed from here

I tried this and I am getting the required result however I want to choose the different linestyle for each of the columns manually:

sns.lineplot(data=df)
1 Answers

Use markers to activate multiple linestyles, and use palette to set all columns to the same color:

sns.lineplot(data=df, markers=True, palette=['blue'] * df.columns.size)

This example uses markers=True which lets seaborn automatically choose the linestyles, but you can also pass a list of matplotlib markers to manually specify your own:

markers : boolean, list, or dictionary

Object determining how to draw the markers for different levels of the style variable. Setting to True will use default markers, or you can pass a list of markers or a dictionary mapping levels of the style variable to markers. Setting to False will draw marker-less lines. Markers are specified as in matplotlib.

Related