【问题标题】:setting ylim on seaborn boxplot在 seaborn boxplot 上设置 ylim
【发布时间】:2017-07-07 12:35:27
【问题描述】:

是否可以在 seaborn 箱线图上设置 ylim 参数?

举个例子:

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

展示

boxplot

但如果我尝试

ax.set_ylim=(-5, 5)

没有区别。是否可以为箱线图设置与给定数据集图的默认值不同的 ylim 值?

【问题讨论】:

    标签: python matplotlib seaborn


    【解决方案1】:

    您在没有轴对象的情况下使用轴方法。

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

    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

    【讨论】:

      猜你喜欢
      • 2018-08-08
      • 1970-01-01
      • 2014-10-02
      • 2018-10-18
      • 1970-01-01
      • 2021-10-29
      • 1970-01-01
      • 2015-08-30
      相关资源
      最近更新 更多