簡體   English   中英

如何設置seaborn boxplot的y軸范圍?

[英]How to set the range of y-axis for a seaborn boxplot?

官方的seaborn文檔中 ,我了解到您可以創建如下框圖

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

Seaborn Boxplot示例

我的問題是:如何限制該圖的y軸范圍? 例如,我希望y軸在[10,40]之內。 有沒有簡單的方法來做到這一點?

它是標准的matplotlib.pyplot:

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

或者更簡單,正如下面的mwaskom評論:

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

在此輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM