我尝试使用 sns seaborn 和 stack 制作直方图,但为什么直方图之间有一些空白?

问题描述 投票:0回答:1

(https://i.stack.imgur.com/UoTLJ.png)

我尝试使用 sns seaborn 和 stack 制作直方图,但为什么直方图之间有一些空白?

sns.histplot(data=airline_df, x="age", Hue="customer_type", multiple="stack")

这是我的代码

我尝试重新运行但不起作用

python-3.x seaborn data-science visualization
1个回答
0
投票
import seaborn as sns

# If you suspect the data is discrete and want to treat it as such
sns.histplot(data=airline_df, x="age", hue="customer_type", multiple="stack", discrete=True)

# If you want to manually specify bin width
sns.histplot(data=airline_df, x="age", hue="customer_type", multiple="stack", binwidth=5)

# If you want to specify custom bin edges
bin_edges = [0, 18, 30, 40, 50, 60, 70, 80, 90, 100]  # Example bin edges
sns.histplot(data=airline_df, x="age", hue="customer_type", multiple="stack", bins=bin_edges)
© www.soinside.com 2019 - 2024. All rights reserved.