Python Seaborn line_kws颜色始终透明

Python Seaborn line_kws颜色始终透明,python,matplotlib,plot,seaborn,alpha,Python,Matplotlib,Plot,Seaborn,Alpha,我用seaborn的line\u kws画了一条我想称之为“最佳拟合”的线。 因为我不知道直线总是透明的,即使我没有定义alpha。 当我运行代码时,会创建一个图,但在“RuntimeWarning:在较大的large=s>cutoff中遇到无效值”之前会出现一个错误。 有人知道我的代码有什么问题吗 sns.regplot(y=power_consumption_pred_train1, x=y_train_ns_m1, line_kws={'lw': 2, 'color': 'red', 'l

我用seaborn的
line\u kws
画了一条我想称之为“最佳拟合”的线。 因为我不知道直线总是透明的,即使我没有定义alpha。 当我运行代码时,会创建一个图,但在“RuntimeWarning:在较大的large=s>cutoff中遇到无效值”之前会出现一个错误。 有人知道我的代码有什么问题吗

sns.regplot(y=power_consumption_pred_train1,
x=y_train_ns_m1,
line_kws={'lw': 2, 'color': 'red', 'label': 'best fit'}
            ).set(ylabel='predicted KWH Consumption (training set)',
                 xlabel='actual KWH Consumption (traning set)')

sns.lineplot(x=(0,3000), y=(0,3000), color='black', label='identity', legend='full', linestyle='dashed'
           ).lines[1]
plt.xlim(0, 3100)
plt.ylim(0, 3000)
plt.show()

问题是一个过时的NumPy版本。它是1.18.0版本,现在与1.19.5版本兼容。

您的问题无法重现。您确定正在运行seaborn的最新版本吗?出于某种原因,只显示置信区间,而不显示回归线本身。置信区间是使用与线条相同颜色但具有高透明度的条带。您可以尝试通过
sns.regplot(..,ci=None)
抑制置信区间。为了使代码更具可复制性,您可以创建一个玩具数据集。例如
y\u train\u ns\u m1=np.random.normal(0,3000,100000);功耗\u pred\u train1=y\u train\u ns\u m1+np.random.uniform(-500500,len(y\u train\u ns\u m1))
我从seaborn获得了0.11.0版,并将其更新为0.11.1,但这并没有改变什么。我可以抑制置信区间,但实际行不会出现。有了玩具数据集,我就有了身份线。缺少最佳拟合和置信区间。我在jupyter实验室和PyCharm有这个问题。所以我认为这一定是seaborn的问题?在使用玩具数据时,尽量不要使用标识线,因为这条线显然会在顶部。也许你改变了一些全球环境?您是否在重新启动Python环境后运行该测试示例?很抱歉,因为它是一个更大代码的一部分,我没有看到错误消息:“RuntimeWarning:在greater large=s>cutoff中遇到无效值”。我想问题出在我的numpy版本。它是1.18.0,现在我将它更新为1.19.5。现在它起作用了。谢谢你的帮助,我很抱歉占用你的时间