为什么在我的jupyter笔记本中,此线图中的线下方填充了seaborn/matplotlib? [英] Why has seaborn/matplotlib filled below the line in this lineplot in my jupyter notebook?

查看:83
本文介绍了为什么在我的jupyter笔记本中,此线图中的线下方填充了seaborn/matplotlib?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道为什么我的情节看起来像这样:

行下方有不想要的填充

我只想显示没有填充的行.下面的代码.请注意,如果我在Spyder或cmd中运行,也会发生这种情况.

import matplotlib.pyplot as plt
import seaborn as sns
df_ard= pd.read_csv(pathx, parse_dates=['Date'] )


plt.figure(figsize=(15,8))

sns.lineplot(x="Date", y='As',
             hue="Location",
             data=df_ard,
             palette='bright')

这是有根据的猜测,因为您没有提供数据(请参见最小,完整和可验证的示例),但我认为阴影来自于您为同一个x值拥有多个y值的事实.

如果您查看 sns.lineplot()的文档,您将阅读:

默认情况下,绘图会在每个值上聚合多个y值 x并显示对集中趋势的估计和置信度 该估算的时间间隔.

有几个选项可以删除阴影:

  • 如果要继续聚合数据,但要删除阴影,请使用ci=None
  • 如果您不想汇总数据,请使用estimator=None

I don't know why my plot looks like this:

I only want to display lines with no fill. Code below. Note this also happens if I run in Spyder or cmd.

import matplotlib.pyplot as plt
import seaborn as sns
df_ard= pd.read_csv(pathx, parse_dates=['Date'] )


plt.figure(figsize=(15,8))

sns.lineplot(x="Date", y='As',
             hue="Location",
             data=df_ard,
             palette='bright')

解决方案

This is an educated guess, since you don't provide your data (see Minimal, Complete, and Verifiable example), but I believe the shading comes from the fact that you have several y-values for the same x-value.

If you look at the documentation for sns.lineplot(), you'll read:

By default, the plot aggregates over multiple y values at each value of x and shows an estimate of the central tendency and a confidence interval for that estimate.

There are several options to remove the shading:

  • if you want to continue aggregating the data, but remove the shading, use ci=None
  • if you want to not aggregate the data, then use estimator=None

这篇关于为什么在我的jupyter笔记本中,此线图中的线下方填充了seaborn/matplotlib?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆