加入最高氣溫
澳洲氣象局很喜歡你為他們製作的圖表,但提出了一個小調整需求。
他們希望你把「絕對最高氣溫」加到先前的圖表中,也就是該日雪梨各地觀測到的最高溫度。
已為你建立 combined_fig,並提供 temp_syd_max DataFrame。
你的任務是把這條新的折線圖加入現有的圖表。
本練習屬於課程
Python 的 Plotly 資料視覺化入門
練習說明
- 建立一個以「絕對最高氣溫」為主題的新增折線圖,命名為
abs_max_line_fig。 - 將它加入現有的
combined_fig,並顯示更新後的圖表。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Figure already created for you
combined_fig = Figure(data=[*daily_temp_fig.data, *monthly_avg_fig.data])
# Create a new line chart
abs_max_line_fig = px.____(temp_syd_max, x='Date', y='Max', color_discrete_sequence=['orange'])
# Add the new trace
combined_fig.____(____.data[0])
# Add a title
combined_fig.update_layout(title='Sydney Temperature Analysis')
# Show the combined figure
combined_fig.show()