如何设置海洋箱形图的y轴范围? [英] How to set the range of y-axis for a seaborn boxplot?

查看:48
本文介绍了如何设置海洋箱形图的y轴范围?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

来自

我的问题是:如何限制该图的 y 轴范围?例如,我希望 y 轴在 [10, 40] 内.有什么简单的方法可以做到这一点吗?

解决方案

这是标准的matplotlib.pyplot:

  ...导入matplotlib.pyplot作为pltplt.ylim(10, 40)

或者更简单,如下面的 mwaskom 评论:

ax.set(ylim=(10, 40))

From the official seaborn documentation, I learned that you can create a boxplot as below:

import seaborn as sns
sns.set_style("whitegrid")
tips = sns.load_dataset("tips")
ax = sns.boxplot(x="day", y="total_bill", data=tips)

My question is: how do I limit the range of y-axis of this plot? For example, I want the y-axis to be within [10, 40]. Is there any easy way to do this?

解决方案

It is standard matplotlib.pyplot:

...
import matplotlib.pyplot as plt
plt.ylim(10, 40)

Or simpler, as mwaskom comments below:

ax.set(ylim=(10, 40))

这篇关于如何设置海洋箱形图的y轴范围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆