简体   繁体   中英

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')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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