Skip to content

Commit

Permalink
Use 51 levels (from 21) for colorbar bins
Browse files Browse the repository at this point in the history
  • Loading branch information
jfrost-mo committed Feb 14, 2025
1 parent ce70ef8 commit 97e0fd4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/CSET/operators/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def _colorbar_map_levels(cube: iris.cube.Cube):
vmin, vmax = var_colorbar["min"], var_colorbar["max"]
logging.debug("Using min and max for %s colorbar.", varname)
# Calculate levels from range.
levels = np.linspace(vmin, vmax, 21)
levels = np.linspace(vmin, vmax, 51)
norm = None
return cmap, levels, norm
except KeyError:
Expand Down
6 changes: 3 additions & 3 deletions tests/operators/test_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def test_colorbar_map_levels(cube, tmp_working_dir):
"""Colorbar definition is found for cube."""
cmap, levels, norm = plot._colorbar_map_levels(cube)
assert cmap == mpl.colormaps["RdYlBu_r"]
assert (levels == np.linspace(223, 323, 21)).all()
assert (levels == np.linspace(223, 323, 51)).all()
assert norm is None


Expand All @@ -108,7 +108,7 @@ def test_colorbar_map_levels_name_fallback(cube, tmp_working_dir):
cube.standard_name = None
cmap, levels, norm = plot._colorbar_map_levels(cube)
assert cmap == mpl.colormaps["RdYlBu_r"]
assert (levels == np.linspace(223, 323, 21)).all()
assert (levels == np.linspace(223, 323, 51)).all()
assert norm is None


Expand All @@ -128,7 +128,7 @@ def test_colorbar_map_levels_pressure_level(transect_source_cube, tmp_working_di
cube_250hPa = transect_source_cube.extract(iris.Constraint(pressure=250))
cmap, levels, norm = plot._colorbar_map_levels(cube_250hPa)
assert cmap == mpl.colormaps["RdYlBu_r"]
assert (levels == np.linspace(200, 240, 21)).all()
assert (levels == np.linspace(200, 240, 51)).all()
assert norm is None


Expand Down

0 comments on commit 97e0fd4

Please sign in to comment.