Create a Figure with an array of two Axes objects that share their y-axis range. Plot Seattle's "MLY-PRCP-NORMAL" in a s

动态 未结 0 131
小小草
小小草 LV1 2023年9月23日 23:40 发表
下面是完整代码: ```python # Create a figure and an array of axes: 2 rows, 1 column with shared y axis fig, ax = plt.subplots(2, 1, sharey=True) # Plot Seattle precipitation data in the top axes ax[0].plot(seattle_weather["MONTH"], seattle_weather["MLY-PRCP-NORMAL"], color="blue") ax[0].plot(seattle_weather["MONTH"], seattle_weather["MLY-PRCP-25PCTL"], color="blue", linestyle="--") ax[0].plot(seattle_weather["MONTH"], seattle_weather["MLY-PRCP-75PCTL"], color="blue", linestyle="--") ax[0].set_title("Seattle") # Plot Austin precipitation data in the bottom axes ax[1].plot(austin_weather["MONTH"], austin_weather["MLY-PRCP-NORMAL"], color="red") ax[1].plot(austin_weather["MONTH"], austin_weather["MLY-PRCP-25PCTL"], color="red", linestyle="--") ax[1].plot(austin_weather["MONTH"], austin_weather["MLY-PRCP-75PCTL"], color="red", linestyle="--") ax[1].set_title("Austin") # Add x-axis labels and a shared y-axis label fig.text(0.5, 0.04, "Month", ha="center") fig.text(0.04, 0.5, "Precipitation (inches)", va="center", rotation="vertical") plt.show() ```
收藏(0)  分享
相关标签: 智能问答
问题没解决?让AI助手帮你作答 AI助手
0个回复
  • 消灭零回复