Mik*_*son 4 python matplotlib seaborn
seaborn是一个漂亮的 Python 包,它在很大程度上充当matplotlib. 然而,它改变了,例如,matplotlib绘图对象上的方法来指导seaborn函数。
seaborn从绘图中删除任何脊柱(绘图的外边缘)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()
Run Code Online (Sandbox Code Playgroud)
感谢所有的精彩评论!我知道你写的一些内容,但不知道和都需要设置。'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()
Run Code Online (Sandbox Code Playgroud)