Seaborn Axis Spines

Learn how to customize and style axis spines in seaborn plots.

Overview

Axis spines are the boundary lines surrounding seaborn plots from four sides (top, bottom, left, and right). We may remove some or all of the spines from the plots according to our needs. We can also customize the spines styling with different colors and line styles. To customize the axis spines, the seaborn library provides the default function sns.despine() to control and alter the plot’s spines.

Press + to interact
Different axis spines in a seaborn plot
Different axis spines in a seaborn plot

Removing axis spines

If we call the sns.despine() function without any parameters, it removes the top and right spines from the plot, as shown in the code below. We first customize the font and theme in the sns.set() function. Next, we plot a regplot between variables var1 and var2 using the sns.regplot() function. Further, we call the sns.despine() function in line 7 to remove the ...