Search⌘ K
AI Features

Seaborn Axis Spines

Explore how to control Seaborn plot boundaries by removing or customizing axis spines. Understand using sns.despine to hide spines and matplotlib functions to adjust color, linewidth, and position. This lesson helps you enhance plot aesthetics and improve readability through detailed spine styling techniques.

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.

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 ...