Python绘制误差带图

例子1


import matplotlib.pyplot as plt

import numpy as np



mean_1 = np.array([10, 20, 30, 25, 32, 43])

std_1 = np.array([2.2, 2.3, 1.2, 2.2, 1.8, 3.5])



mean_2 = np.array([12, 22, 30, 13, 33, 39])

std_2 = np.array([2.4, 1.3, 2.2, 1.2, 1.9, 3.5])



x = np.arange(len(mean_1))

plt.plot(x, mean_1, 'b-', label='mean_1')

plt.fill_between(x, mean_1 - std_1, mean_1 + std_1, color='b', alpha=0.2)

plt.plot(x, mean_2, 'r-', label='mean_2')

plt.fill_between(x, mean_2 - std_2, mean_2 + std_2, color='r', alpha=0.2)

plt.legend()

plt.show()

例子2

import matplotlib.pyplot as plt

import numpy as np

import seaborn as sns



sns.set()

N = 100

x = np.arange(N)

mean_1 = 25 + np.random.normal(0.1, 1, N).cumsum()

std_1 = 3 + np.random.normal(0, .08, N).cumsum()



mean_2 = 15 + np.random.normal(0.2, 1, N).cumsum()

std_2 = 4 + np.random.normal(0, .1, N).cumsum()



plt.plot(x, mean_1, 'b-', label='mean_1')

plt.fill_between(x, mean_1 - std_1, mean_1 + std_1, color='b', alpha=0.2)

plt.plot(x, mean_2, 'r--', label='mean_2')

plt.fill_between(x, mean_2 - std_2, mean_2 + std_2, color='r', alpha=0.2)



plt.legend(title='title')

plt.show()
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值