Skip to content

Commit 7903a3f

Browse files
Update recipe 19: gopen & gclose in same block for plot to emerge
1 parent 4c0d6f5 commit 7903a3f

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

docs/source/recipes/plot_19_recipe.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,17 @@
4646
}
4747

4848
# %%
49-
# 6. Create and open the plot file:
50-
cfp.gopen(
51-
rows=2, columns=1, bottom=0.1, top=0.85, file="global_avg_sst_plot.png"
52-
)
53-
54-
# %%
55-
# 7. Put maxima subplot at top since these values are higher, given
56-
# increasing x axis. Note we set limits manually with 'gset' only to
49+
# 6. Create and open the plot file. Put maxima subplot at top since these
50+
# values are higher, given increasing x axis.
51+
# Note we set limits manually with 'gset' only to
5752
# allow space so the legend doesn't overlap the data, which isn't
5853
# possible purely from positioning it anywhere within the default plot.
5954
# Otherwise cf-plot handles this for us. To plot the per-season means
6055
# of the maxima, we loop through the season query mapping and do a
6156
# "T: mean" collapse setting the season as the grouping:
57+
cfp.gopen(
58+
rows=2, columns=1, bottom=0.1, top=0.85, file="global_avg_sst_plot.png"
59+
)
6260
cfp.gpos(1)
6361
cfp.gset(xmin="1980-01-01", xmax="2022-12-01", ymin=304, ymax=312)
6462
for colour, season_query in colours_seasons_mapping.items():
@@ -78,11 +76,9 @@
7876
xlabel="",
7977
label="All months",
8078
)
81-
82-
# %%
83-
# 8. Create and add minima subplot below the maxima one. Just like for the
79+
# Create and add minima subplot below the maxima one. Just like for the
8480
# maxima case, we plot per-season means by looping through the season query
85-
# mapping and doing a "T: mean" collapse setting the season as the grouping:
81+
# mapping and doing a "T: mean" collapse setting the season as the grouping
8682
cfp.gpos(2)
8783
cfp.gset(xmin="1980-01-01", xmax="2022-12-01", ymin=269, ymax=272)
8884
for colour, season_query in colours_seasons_mapping.items():
@@ -100,9 +96,7 @@
10096
am_min,
10197
color="grey",
10298
)
103-
104-
# %%
105-
# 9. Add an overall title to the plot and close the file to save it:
99+
# Add an overall title to the plot and close the file to save it
106100
plt.suptitle(
107101
"Global mean sea surface temperature (SST) monthly\nminima and maxima "
108102
"showing seasonal means of these extrema",

0 commit comments

Comments
 (0)