使用seaborn中的lineplot时,x轴上的数据点缺失

2024-09-29 21:26:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在绘制一些数据,这些数据有日期和每个域的得分,所以x轴有日期,y轴有得分(0-10),每个图是针对不同的域。你知道吗

我的数据有13个日期(在x轴上有13个点),但是在绘图时我只有8个日期!你知道吗

我已经检查了lineplot的输入,它有所有13个日期。你知道吗

for domain in behaviors:
    fig,ax = plt.subplots()
    ax = sns.lineplot(x = 'submitted_at', y = str(domain), data = c53_behaviorl_T.iloc[0:13,:].reset_index(), lw = 3)
    ax.set_xticklabels(c53_behaviorl_T.reset_index().submitted_at,rotation=45)
    ax.set(xlabel = 'Date', ylabel = 'Score', title = domain)

这是我在运行输入数据时得到的结果:

question submitted_at        ...         water preference
0          2018-05-08        ...                        0
1          2018-05-21        ...                        1
2          2018-05-28        ...                        0
3          2018-06-06        ...                        0
4          2018-06-26        ...                        0
5          2018-07-27        ...                        0
6          2018-07-31        ...                        0
7          2018-09-12        ...                        0
8          2018-09-26        ...                        0
9          2018-10-12        ...                        0
10         2018-10-30        ...                        0
11         2018-12-06        ...                        0
12         2018-12-15        ...                        0

[13 rows x 20 columns]

但我的测线图在第7天(2018-09-12)停止。你知道吗


Tags: 数据in绘图forindexdomain绘制ax

热门问题