擅长:python、mysql、java
<p>在<strong>Seaborn v0.8.0(2017年7月)</strong>中,增加了使用误差条显示标准偏差的能力,而不是通过设置ci=“sd”在大多数统计函数中引导置信区间。所以这个现在有效了</p>
<pre><code>sns.tsplot(data=data, ci="sd")
</code></pre>
<p><strong>对于以前的Seaborn版本,绘制标准偏差的解决方法是在Seaborn tsplot的顶部使用matplotlib错误栏:</p>
<pre><code>import numpy as np;
import seaborn as sns;
import pandas as pd
import matplotlib.pyplot as plt
# create a group of time series
num_samples = 90
group_size = 10
x = np.linspace(0, 10, num_samples)
group = np.sin(x) + np.linspace(0, 2, num_samples) + np.random.rand(group_size, num_samples) + np.random.randn(group_size, 1)
df = pd.DataFrame(group.T, index=range(0,num_samples))
# plot time series with seaborn
ax = sns.tsplot(data=df.T.values) #, err_style="unit_traces")
# Add std deviation bars to the previous plot
mean = df.mean(axis=1)
std = df.std(axis=1)
ax.errorbar(df.index, mean, yerr=std, fmt='-o') #fmt=None to plot bars only
plt.show()
</code></pre>
<p><a href="https://i.stack.imgur.com/ljP4p.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ljP4p.png" alt="enter image description here"/></a></p>