Skip to content

Commit e18b90b

Browse files
Apply line-wrapping & numbering fix NH original recipe 17
1 parent d4cb7e3 commit e18b90b

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

docs/source/recipes/plot_17_recipe.py

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
"""
2-
Plotting Contour Subplots with different Colour Maps/Scales
3-
============================================
2+
Plotting contour subplots with different colour maps/scales
3+
===========================================================
4+
45
In this recipe, we will plot data with different colour maps to illustrate
56
the importance of choosing the correct one for a plot. This is to ensure
67
the use of perceptually uniform scales and avoid unintended bias.
8+
79
"""
810

911
# %%
@@ -15,9 +17,8 @@
1517

1618
# %%
1719
# 2. Read the field in:
18-
# Here I've used sample data ggap.nc (and later pressure=850), but you could use tas_A1.nc
19-
# (with time=15)
20-
20+
# Here I've used sample data ggap.nc (and later pressure=850), but you
21+
# could use tas_A1.nc (with time=15)
2122
PATH="~/git-repos/cf-plot/cfplot/test/cfplot_data"
2223
f = cf.read(f"{PATH}/ggap.nc")[0]
2324

@@ -26,18 +27,16 @@
2627
# Choose a set of predefined colour scales to view (based on NCAR)
2728
# You could also choose your own from
2829
# https://ncas-cms.github.io/cf-plot/build/colour_scales.html
29-
# Simply change the name in quotes and ensure the number of rows * number of columns =
30-
# number of colour scales
30+
# Simply change the name in quotes and ensure the
31+
# number of rows * number of columns = number of colour scales
3132

3233
# %%
3334
# a. Perceptually uniform colour scales, with no zero value
34-
3535
colour_scale = ["viridis", "magma", "inferno", "plasma", "parula", "gray"]
3636
cfp.gopen(rows=2, columns=3, bottom=0.2)
3737

3838
# %%
3939
# b. NCAR Command Language - Enhanced to help with colour blindness
40-
4140
colour_scale = [
4241
"StepSeq25",
4342
"posneg_2",
@@ -53,12 +52,10 @@
5352

5453
# %%
5554
# c. Orography/bathymetry colour scales
56-
57-
# These are used to show the shape/contour of landmasses, bear in mind the example data
58-
# we use is with pressure so doesnt accurately represent this.
59-
# You could instead use cfp.cscale('wiki_2_0', ncols=16, below=2, above=14) or any other
60-
# orography colour scale in a similar way
61-
55+
# These are used to show the shape/contour of landmasses, bear in mind the
56+
# example data we use is with pressure so doesnt accurately represent this.
57+
# You could instead use cfp.cscale('wiki_2_0', ncols=16, below=2, above=14)
58+
# or any other orography colour scale in a similar way.
6259
colour_scale = [
6360
"os250kmetres",
6461
"wiki_1_0_2",
@@ -70,9 +67,9 @@
7067
cfp.gopen(rows=2, columns=3, bottom=0.2, file="ColourPlot.png")
7168

7269
# %%
73-
# 5. We then use a for loop to cycle through all the different colour maps:
74-
# Only gpos has 1 added because it can only take 1 as its first value, otherwise there are
75-
# errors.
70+
# 4. We then use a for loop to cycle through all the different colour maps:
71+
# Only gpos has 1 added because it can only take 1 as its first value,
72+
# otherwise there are errors.
7673
for i, colour_scale in enumerate(colour_scale):
7774
cfp.gpos(i + 1)
7875
cfp.mapset(proj="cyl")

0 commit comments

Comments
 (0)