Skip to content

Commit 390a7c9

Browse files
Self-review: simplify logic in updated Natalia recipe 17
1 parent 8c717a7 commit 390a7c9

File tree

1 file changed

+24
-34
lines changed

1 file changed

+24
-34
lines changed

docs/source/recipes/plot_17_recipe.py

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
# %%
2020
# 2. Read the field in:
21-
f = cf.read(f"~/recipes/ggap.nc")[0]
21+
f = cf.read("~/recipes/ggap.nc")[0]
2222

2323
# %%
2424
# 3. Choose a set of predefined colour scales to view. These can be chosen
@@ -84,41 +84,31 @@
8484
cfp.gpos(i + 1)
8585
cfp.cscale(colour_scale)
8686

87-
# For the topmost plots, label the coumn with the colour scale category
87+
# For the topmost plots, label the column with the colour scale category
8888
# using the 'title' argument, otherwise don't add a title.
89-
if i < 3:
90-
# Ensure the order the titles are written in corresponds to the
91-
# order unzipped in step 4, so the columns match up correctly.
92-
if i == 0:
93-
set_title = "Perceptually uniform\ncolour maps"
94-
elif i == 1:
95-
set_title = (
96-
"NCL colour maps enhanced to \nhelp with colour blindness"
97-
)
98-
elif i == 2:
99-
set_title = "Orography/bathymetry\ncolour maps"
100-
101-
cfp.con(
102-
f.subspace(pressure=850),
103-
title=set_title,
104-
lines=False,
105-
axes=False,
106-
colorbar_drawedges=False,
107-
colorbar_title=f"Shown in '{colour_scale}'",
108-
colorbar_fraction=0.04,
109-
colorbar_thick=0.02,
110-
colorbar_fontsize=11,
89+
# Ensure the order the titles are written in corresponds to the
90+
# order unzipped in step 4, so the columns match up correctly.
91+
if i == 0:
92+
set_title = "Perceptually uniform\ncolour maps"
93+
elif i == 1:
94+
set_title = (
95+
"NCL colour maps enhanced to \nhelp with colour blindness"
11196
)
97+
elif i == 2:
98+
set_title = "Orography/bathymetry\ncolour maps"
11299
else:
113-
cfp.con(
114-
f.subspace(pressure=850),
115-
lines=False,
116-
axes=False,
117-
colorbar_drawedges=False,
118-
colorbar_title=f"Shown in '{colour_scale}'",
119-
colorbar_fraction=0.04,
120-
colorbar_thick=0.02,
121-
colorbar_fontsize=11,
122-
)
100+
set_title = ""
101+
102+
cfp.con(
103+
f.subspace(pressure=850),
104+
title=set_title,
105+
lines=False,
106+
axes=False,
107+
colorbar_drawedges=False,
108+
colorbar_title=f"Shown in '{colour_scale}'",
109+
colorbar_fraction=0.04,
110+
colorbar_thick=0.02,
111+
colorbar_fontsize=11,
112+
)
123113

124114
cfp.gclose(view=True)

0 commit comments

Comments
 (0)