90 與 95% 帶狀區間
你現在看到的是辛辛那提市 2013 年 NO2 汙染濃度的 40 日移動平均。為了更完整呈現趨勢中的不確定性,你想同時查看此移動估計周圍的 90% 與 99% 區間。
請設定兩種區間範圍,以及一組橘色的序階色盤。此外,為了讓帶狀區間更容易精確讀取,請將它們設為半透明,讓 Seaborn 的背景格線可以透出。
本練習屬於課程
用 Python 改善你的資料視覺化
練習說明
- 將區間的不透明度設為 40%。
- 計算信賴區間的下界與上界。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
int_widths = ['90%', '99%']
z_scores = [1.67, 2.58]
colors = ['#fc8d59', '#fee08b']
for percent, Z, color in zip(int_widths, z_scores, colors):
# Pass lower and upper confidence bounds and lower opacity
plt.fill_between(
x = cinci_13_no2.day, alpha = ____, color = color,
y1 = cinci_13_no2['mean'] ____ ____*cinci_13_no2['std_err'],
y2 = cinci_13_no2['mean'] ____ ____*cinci_13_no2['std_err'],
label = percent)
plt.legend()
plt.show()