這個領域存在多個問題,但是我不能用它們來解決我的問題。我有一個資料樣本,我想為其曲線創建置信區間。在這里,我提供一個簡單的例子:
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
mean, lower, upper = [],[],[]
ci = 0.2
for i in range (20):
a = np.random.rand(100) # this is the output
MEAN = np.mean(a)
mean.append(MEAN)
std = np.std(a)
Upper = MEAN ci*std
Lower = MEAN-ci*std
lower.append(Lower)
upper.append(Upper)
plt.figure(figsize=(20,8))
plt.plot(mean,'-b', label='mean')
plt.plot(upper,'-r', label='upper')
plt.plot(lower,'-g', label='lower')
plt.xlabel("Value", fontsize = 30)
plt.ylabel("Loss", fontsize = 30)
plt.xticks(fontsize= 30)
plt.yticks(fontsize= 30)
plt.legend(loc=4, prop={'size': 30})
在上面的例子中,我畫了
標籤:Python matplotlib 上一篇:如何保持pyplot軸僅根據一個圖縮放而不擴展到其他圖? 下一篇:更改日期格式
