简体   繁体   English

Seaborn 如何在折线图中获得这条线(置信界限)?

[英]Seaborn how do I get this line (condifence bounds) in the line plot?

I have a problem.我有个问题。 I would like to display the frequency of the months in a linear progression.我想以线性进度显示月份的频率。 In doing so, I group the months and show them linearly.这样做时,我将月份分组并线性显示。 I would like to get this blue thick line.我想得到这条蓝色粗线。 How do I get this thick blue line (condifence bounds)?我如何得到这条粗蓝线(置信界限)?

d = {
    "customerId": [1, 1, 1, 1, 1, 2, 3, 3],
    "fromDate": [
        "2022-06-01",
        "2022-05-25",
        "2022-05-25",
        "2022-05-20",
        "2021-09-05",
        "2022-06-02",
        "2021-03-01",
        "2021-02-01",
    ],
    "sales": [100, 20, 50, 30, 40, 80, 50, 20],
}
df = pd.DataFrame(data=d)
df["fromDate"] = pd.to_datetime(df["fromDate"], errors="coerce")

df['fromDate_month'] = pd.to_datetime(df['fromDate'], errors='coerce').dt.month
df_month = df['fromDate_month']
plt.figure(figsize=(14,5))
ax = sns.lineplot(x=df_month.value_counts().index, y=df_month.value_counts())

What I have我有的在此处输入图像描述

What I want我想要的是

在此处输入图像描述

Your second plot has upper and lower bounds confidence bounds.你的第二个情节有上限和下限置信区间。 Your first chart is what you get with your made dataframe, is the problem style of the plot or you also want the condifence bounds?您的第一个图表是您使用制作的数据框得到的,是绘图的问题样式还是您还想要置信范围?
If yes then do this before running plot:如果是,则在运行绘图之前执行此操作:

import matplotlib.pyplot as plt
%matplotlib inline
plt.style.use('seaborn')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM