How to increase the line thickness of a Seaborn Line?

To increase the line thickness of a Seaborn line plot, you can use the linewidth parameter (or its shorthand lw) in the lineplot() function. This parameter controls how thick the line appears in your visualization.

Basic Example

Here's how to create a line plot with increased thickness ?

import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np

# Create sample data
df = pd.DataFrame({
    'time': list(pd.date_range("2021-01-01 12:00:00", periods=10)),
    'speed': np.linspace(1, 10, 10)
})

# Create line plot with thick line (linewidth=7)
plt.figure(figsize=(8, 4))
ax = sns.lineplot(x="time", y="speed", data=df, linewidth=7)
ax.tick_params(axis='x', rotation=45)
plt.tight_layout()
plt.show()

Comparing Different Line Widths

Let's compare different linewidth values to see the effect ?

import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np

# Create sample data
x = np.linspace(0, 10, 20)
df = pd.DataFrame({
    'x': x,
    'y1': np.sin(x),
    'y2': np.sin(x) + 0.5,
    'y3': np.sin(x) + 1
})

plt.figure(figsize=(10, 6))

# Plot lines with different thicknesses
sns.lineplot(x='x', y='y1', data=df, linewidth=1, label='linewidth=1')
sns.lineplot(x='x', y='y2', data=df, linewidth=3, label='linewidth=3') 
sns.lineplot(x='x', y='y3', data=df, linewidth=6, label='linewidth=6')

plt.legend()
plt.title('Comparison of Different Line Widths')
plt.show()

Using the Shorthand Parameter

You can also use lw instead of linewidth for shorter syntax ?

import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np

# Sample data
data = pd.DataFrame({
    'month': ['Jan', 'Feb', 'Mar', 'Apr', 'May'],
    'sales': [100, 120, 140, 110, 160]
})

plt.figure(figsize=(8, 5))
sns.lineplot(x='month', y='sales', data=data, lw=5, marker='o', markersize=8)
plt.title('Sales Trend with Thick Line')
plt.show()

Key Parameters

Parameter Description Example Values
linewidth or lw Controls line thickness 1 (thin), 3 (medium), 7 (thick)
linestyle Line style pattern '-', '--', '-.', ':'
color Line color 'red', '#FF5733', 'blue'

Conclusion

Use the linewidth or lw parameter in sns.lineplot() to control line thickness. Higher values create thicker lines, with typical values ranging from 1 (thin) to 10 (very thick) depending on your visualization needs.

Updated on: 2026-03-26T15:04:33+05:30

4K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements