开始使用免费开始使用

添加最高气温

澳大利亚气象局非常喜欢您之前制作的图表,但提出了一个修改请求。

他们希望您在之前的图表上再添加一条"绝对最高气温"曲线,也就是当天悉尼任意地点观测到的最高气温。

系统已为您创建了 combined_fig,并提供了 temp_syd_max 数据框。

您的任务是将这条新的折线图添加到现有图表中。

本练习是课程的一部分

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()
编辑并运行代码