2017-07-07 198 views
1

是否可以在seaborn boxplot上设置ylim参数?在seaborn boxplot上设置ylim

为例:

y = np.random.randn(300) 
sns.boxplot (y=y) 

显示

boxplot

但如果我尝试

ax.set_ylim=(-5, 5) 

这没有什么区别。是否有可能为boxplot设置不同于给定数据集图的默认值的ylim值?

回答

2

您可以使用没有轴对象的坐标轴方法。

尝试(基于图形的方法):

import matplotlib.pyplot as plt 
plt.ylim([-5,5]) 

或者可能你的情况更好:

ax = sns.boxplot (y=y) 
ax.set_ylim([-5, 5])  # function! your code-sample is wrong here! 

docs here显示sns.boxplot的返回值。

here is the general overview of matplotlib's objects