Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

seaborn: despine plots by default

matplotlib.pyplot.figure()
....
seaborn.despine(offset=10)

The despine function of seaborn offsets the axis spines from the plot, which looks quite nice. The function needs to be called after the code that plots a figure. However, I would like this to be the default for any plot, at least any seaborn plot. How can this be configured?

Alternatively, how can this be made part of a plotting context?

like image 585
clstaudt Avatar asked Oct 12 '25 12:10

clstaudt


1 Answers

Matplotlib added rc params to control spine visibility in version 1.5, so you could turn off the visibility of the top and right spines by default with

import matplotlib.pyplot as plt
plt.rc("axes.spines", top=False, right=False)

However, matplotlib does not expose spine offsets through the rc params, so there is no setting that will automatically apply those to every plot.

like image 177
mwaskom Avatar answered Oct 15 '25 06:10

mwaskom