在Python的Seaborn中,有什么办法可以做到与`despine`相反的事情吗?

In Python's Seaborn, is there any way to do the opposite of `despine`?

seaborn 是一个漂亮的 Python 包,在大多数情况下,它作为 matplotlib 之上的附加层。然而,它改变了,例如,绘图对象上的 matplotlib 方法来指导 seaborn 函数。


seaborn's despine() 从绘图中删除 任何脊柱(绘图的外边缘)。但我不能反其道而行之。

如果我从一开始就完全使用 matplotlib,我似乎无法以标准方式重新创建脊柱。有没有办法做到这一点?我会怎样?


下面是一个例子。例如,我可以在绘图的底部和左侧添加一个书脊吗?

from sklearn import datasets
import pandas as pd

tmp = datasets.load_iris()
iris = pd.DataFrame(tmp.data, columns=tmp.feature_names)
iris['species'] = tmp.target_names[tmp.target]
iris.species =  iris.species.astype('category') 

import seaborn as sns
import matplotlib.pyplot as plt
sns.set_style('darkgrid')
sns.boxplot(x='species', y='sepal length (cm)', data=iris_new)
plt.show()

感谢所有精彩评论!我知道你写的一些东西,但不知道 'axes.linewidth' 'axes.edgecolor'需要设置

我在这里写一个答案,因为它是一些评论的汇编。


也就是说,下面的代码生成如下图:

sns.set_style('darkgrid', {'axes.linewidth': 2, 'axes.edgecolor':'black'})
sns.boxplot(x='species', y='sepal length (cm)', data=iris_new)
plt.show()