Table of Contents
Seaborn is a popular data visualization library in Python that offers a variety of customizable options for creating appealing and informative plots. One such option is adjusting the line thickness in plots, which can greatly impact the overall look and readability of the visualizations. To adjust the line thickness in Seaborn, users can utilize the `linewidth` parameter in the `sns.lineplot()` function. This parameter allows for specifying the desired thickness of the lines in the plot. By adjusting this parameter, users can easily fine-tune the appearance of their plots to meet their specific needs and preferences.
Adjust Line Thickness in Seaborn (With Example)
You can use the linewidth argument within the lineplot() function to adjust the line thickness in seaborn plots:
import seaborn as sns sns.lineplot(data=df, x='x_var', y='y_var', linewidth=2)
The greater the value you provide, the thicker the line will be.
The following example shows how to use this syntax in practice.
Example: Adjust Line Thickness in Seaborn
Suppose we have the following pandas DataFrame that contains information about the sales made each day at some retail store:
import pandas as pd
#create DataFrame
df = pd.DataFrame({'day': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
'sales': [3, 3, 5, 4, 5, 6, 8, 9, 14, 18]})
#view DataFrame
print(df)
day sales
0 1 3
1 2 3
2 3 5
3 4 4
4 5 5
5 6 6
6 7 8
7 8 9
8 9 14
9 10 18
We can use the lineplot() function in seaborn to create a line plot with a default line width:
import seaborn as sns #create line plot with default line width sns.lineplot(data=df, x='day', y='sales')

To increase the line width, we can use the linewidth argument:
import seaborn as sns #create line plot with increased line width sns.lineplot(data=df, x='day', y='sales', linewidth=4)

Notice that the line is much thicker in this plot.
Also note that you can use lw as shorthand for “linewidth” if you’d like:
import seaborn as sns #create line plot with increased line width sns.lineplot(data=df, x='day', y='sales', lw=4)

Also note that if you create a , the linewidth argument will affect the thickness of each line in the plot.
Note: If you have trouble importing seaborn in a Jupyter notebook, you may first need to run the command %pip install seaborn.
The following tutorials explain how to perform other common tasks in seaborn:
Cite this article
stats writer (2024). How can I adjust the line thickness in Seaborn?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-can-i-adjust-the-line-thickness-in-seaborn/
stats writer. "How can I adjust the line thickness in Seaborn?." PSYCHOLOGICAL SCALES, 25 Jun. 2024, https://scales.arabpsychology.com/stats/how-can-i-adjust-the-line-thickness-in-seaborn/.
stats writer. "How can I adjust the line thickness in Seaborn?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/how-can-i-adjust-the-line-thickness-in-seaborn/.
stats writer (2024) 'How can I adjust the line thickness in Seaborn?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-can-i-adjust-the-line-thickness-in-seaborn/.
[1] stats writer, "How can I adjust the line thickness in Seaborn?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, June, 2024.
stats writer. How can I adjust the line thickness in Seaborn?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.
