python的误差条形图的解释_Python中的seaborn tsplot函数的标准偏差和误差条

绘制标准偏差的另一个解决方法可能是在seaborn tsplot的顶部使用matplotlib错误栏:

import numpy as np;

import seaborn as sns;

import pandas as pd

# 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()

1b635c69ff3a80fcd096b8828ce2e0c4.png

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值