gpt4 book ai didi

python - Seaborn 一张图上的两个地 block : x-values are is off by one

转载 作者:行者123 更新时间:2023-11-28 17:08:43 24 4
gpt4 key购买 nike

<分区>

我在 seaborn 中绘制两个重叠的图时遇到了奇怪的行为。条形图似乎工作正常,但 regplot 似乎偏离了一个。请注意缺少 x=1 的 reg 数据点,并将 x=2 值与下表中 x 的值进行比较,显然相差 1。

enter image description here

我的 pandas 数据框如下所示:

    Threshold per Day   # Alarms    Percent Reduction
0 1 791 96.72
1 2 539 93.90
2 3 439 91.94
3 4 361 89.82
4 5 317 88.26
5 6 263 85.94
6 7 233 84.41
7 8 205 82.78
8 9 196 82.17
9 10 176 80.66

我在这里使用的代码是:

%matplotlib inline

import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

fig, ax = plt.subplots()

ax2 = ax.twinx()
sns.barplot(x='Threshold per Day', y="# Alarms", data=results_df, ax=ax, color='lightblue')
sns.regplot(x='Threshold per Day', y='Percent Reduction', data=results_df, marker='x', fit_reg=False, ax=ax2)

知道发生了什么或如何解决它吗?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com