Skip to content

Commit 05c8b40

Browse files
Finalise GP recipe 19 plot and functional code
1 parent 1543841 commit 05c8b40

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

docs/source/recipes/plot_19_recipe.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,14 @@
1818

1919
# Collapse data by area mean (average over spatial dimensions)
2020
am_max = sst.collapse("area: maximum") # equivalent to "X Y: mean"
21-
am_min = sst.collapse("area: minimum") # equivalent to "X Y: mean"
22-
print("AM SEASONAL IS", am_min, am_max)
21+
am_min = sst.collapse("area: minimum")
2322

2423
# Reduce all timeseries down to just 1980+ since there are some data
2524
# quality issues before 1970
2625
am_max = am_max.subspace(T=cf.ge(cf.dt("1980-01-01")))
2726
am_min = am_min.subspace(T=cf.ge(cf.dt("1980-01-01")))
28-
print("FINAL FIELDS ARE", am_max, am_min)
2927

30-
# TODO
28+
# TODO COMMENT
3129
colours_seasons_map = {
3230
"red": (cf.mam(), "Mean across MAM: March, April and May"),
3331
"blue": (cf.jja(), "Mean across JJA: June, July and August"),
@@ -36,7 +34,7 @@
3634
}
3735

3836
cfp.gopen(
39-
rows=2, columns=1, bottom=0.1, top=0.75, file="global_avg_sst_plot.png")
37+
rows=2, columns=1, bottom=0.1, top=0.85, file="global_avg_sst_plot.png")
4038

4139
# Put maxima subplot at top since these values are higher, given
4240
# increasing x axis
@@ -46,6 +44,9 @@
4644
"including seasonal means of these extrema",
4745
fontsize=18,
4846
)
47+
# Set limits manually only to allow space so the legend doesn't overlap the
48+
# data, which isn't possible purely from positioning it anywhere
49+
cfp.gset(xmin="1980-01-01", xmax="2022-12-01", ymin=304, ymax=312)
4950
for colour, season_query in colours_seasons_map.items():
5051
query_on_season, season_description = season_query
5152
am_sub = am_max.collapse("T: mean", group=query_on_season)
@@ -54,21 +55,19 @@
5455
color=colour,
5556
markeredgecolor=colour,
5657
marker="o",
57-
xlabel="",
5858
label=season_description,
5959
title="Maxima per month or season",
60-
# TODO FONTSIZE HERE
6160
)
6261
cfp.lineplot(
6362
am_max,
6463
color="grey",
6564
xlabel="",
66-
ylabel="Temperature (K)",
67-
label="All months"
65+
label="All months",
6866
)
6967

7068
# Minima subplot below the maxima one
7169
cfp.gpos(2)
70+
cfp.gset(xmin="1980-01-01", xmax="2022-12-01", ymin=269, ymax=272)
7271
for colour, season_query in colours_seasons_map.items():
7372
query_on_season, season_description = season_query
7473
am_sub = am_min.collapse("T: mean", group=query_on_season)

0 commit comments

Comments
 (0)