In this article, we are going to learn how to Seaborn Multiple Line Plot Pandas DataFrame using the Seaborn module. We will learn this with the help of coding examples and the visual output in the form of a plot by using some sample data from Pandas’ dataframe.
1. Seaborn Multiple Line Plot Pandas dataframe
In this article, we are going to learn how to draw a multiple-line plot by using the Seaborn module. We will learn this with the help of coding examples and the visual output in the form of a plot by using some sample data.
seaborn.lineplot(*, x=None, y=None, hue=None, size=None, style=None, data=None,palette=None, hue_order=None, hue_norm=None, sizes=None, size_order=None,size_norm=None, dashes=True, markers=None, style_order=None, units=None,
estimator='mean', ci=95, n_boot=1000, seed=None, sort=True, err_style='band',err_kws=None, legend='auto', ax=None, **kwargs)
You can learn about all its arguments at https://seaborn.pydata.org/generated/seaborn.lineplot.html.
1. Seaborn plot multiple lines
We are going to see how we can use the lineplot() function to plot multiple lines where each line represents data. To plot multiple lines we must have the data of each line. if this data is unformatted data, we must convert it into a panda dataframe where we align each line of data to each column of this data frame. Once we have this formatted data in the form of a panda dataframe, we can plot this panda dataframe on the plot by using the lineplot() function. so let us see this with the help of a code example.
import seaborn as sns
import pandas as pd
import matplotlib.pyplot as pltsw
array = [[1,10,0,2,0],
[3,5,0,1,0],
[0,11,3,0,2],
[0,0,12,0,0],
[0,9,0,13,0],
[0,13,0,0,11]]
DetaFrame_multiplot = pd.DataFrame(array, range(6), range(5))
sns.lineplot(data=DetaFrame_multiplot)
pltsw.show()
Output

Explanation:
- We are importing the seaborn module to our program.
- import seaborn as sns
- We are importing the panda’s module to our program.
- import pandas as pd
- We are importing the matplotlib module’s pyplot to our program to display the plot.
- import matplotlib.pyplot as pltsw
- We are taking a sample array of random values.
- array = [[1,10,0,2,0],
[3,5,0,1,0],
[0,11,3,0,2],
[0,0,12,0,0],
[0,9,0,13,0],
[0,13,0,0,11]]
- array = [[1,10,0,2,0],
- We are next converting this array to a panda dataframe with size of 6 rows and 5 columns.
- DetaFrame_multiplot = pd.DataFrame(array, range(6), range(5))
- Finally, we are calling the lineplot() function on this dataframe, by just passing this dataframe to lineplot() function.
- sns.lineplot(data=DetaFrame_multiplot) The lineplot() function will act on the values that are in the columns of the data frame as the y-axis values.It will use the index of the values as the x-axis values to plot the lines.
- The last and important step is to call the show function to show the plot on screen.
- pltsw.show()
2. Seaborn multiple line plot with markers
We are going to see how we can use the lineplot() function to plot multiple lines with markers. Also we will see how we can set the palette, line width, and other properties.lineplot function takes several other arguments that are used to enhance the visibility of the plot like markers,palette, legend, linewidth etc.
- The markers argument of the lineplot() function is used to plot markers inside the lines. If you don’t pass this argument then it is false by default.
But if you pass this as true, then lineplot function handles the markers itself. Also, you have the option to pass the symbols in markers as an argument if you want to handle it yourself. - We have another argument that is “ms” means marker size, you can pass this as the desired size of the markers.
- We have “mfc” argument which is a marker face color, that is used to set the color. You can use the first letter of color to pass as an argument.
- “mec” is the marker edge color argument, you can use the first letter of color to pass as an argument.
- The linewidth is another argument to set the width of each line that we are plotting on this plot. so let us see this with the help of a code example.
import seaborn as sns
import pandas as pd
import matplotlib.pyplot as pltsw
array = [[1,10,0,2,0],
[3,5,0,1,0],
[0,11,3,4,2],
[4,0,12,0,0],
[0,9,0,13,0],
[5,13,0,0,11]]
DetaFrame_multiplot = pd.DataFrame(array, range(6), range(5))
sns.lineplot(data=DetaFrame_multiplot,markers=['p','d','h','p','*'],palette='dark', legend=False, linewidth=2,ms=15, mec='r',mew=2,mfc='g')
pltsw.show()
Output
