Skip to content

Commit bf5f338

Browse files
committed
Remove default cmap of "jet"
This will fall back to matplotlibs configured default, which is usually 'viridis' but can be customised by users. "jet" is a poor choice for many reasons.
1 parent 9187713 commit bf5f338

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

docs/_static/images/gbr4_temp.png

5.1 KB
Loading

src/emsarray/plot.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def add_landmarks(
130130
# Plot the temperature
131131
temperature = dataset.ems.make_poly_collection(
132132
dataset['temp'].isel(time=0, k=-1),
133-
cmap='jet', edgecolor='face', zorder=0)
133+
cmap='viridis', edgecolor='face', zorder=0)
134134
axes.add_collection(temperature)
135135
figure.colorbar(temperature, label='°C')
136136
@@ -321,7 +321,7 @@ def plot_on_figure(
321321
if scalar is not None:
322322
# Plot a scalar variable on the polygons using a colour map
323323
collection = convention.make_poly_collection(
324-
scalar, cmap='jet', edgecolor='face')
324+
scalar, edgecolor='face')
325325
axes.add_collection(collection)
326326
units = scalar.attrs.get('units')
327327
figure.colorbar(collection, ax=axes, location='right', label=units)
@@ -437,7 +437,7 @@ def animate_on_figure(
437437
# Plot a scalar variable on the polygons using a colour map
438438
scalar_values = convention.ravel(scalar).values[:, convention.mask]
439439
collection = convention.make_poly_collection(
440-
cmap='jet', edgecolor='face',
440+
edgecolor='face',
441441
clim=(numpy.nanmin(scalar_values), numpy.nanmax(scalar_values)))
442442
axes.add_collection(collection)
443443
collection.set_animated(True)

src/emsarray/transect.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import shapely
99
import xarray
1010
from cartopy import crs
11-
from matplotlib import animation, colormaps, pyplot
11+
from matplotlib import animation, pyplot
1212
from matplotlib.artist import Artist
1313
from matplotlib.axes import Axes
1414
from matplotlib.collections import PolyCollection
@@ -558,7 +558,7 @@ def plot_on_figure(
558558
trim_nans: bool = True,
559559
clamp_to_surface: bool = True,
560560
bathymetry: xarray.DataArray | None = None,
561-
cmap: str | Colormap = 'jet',
561+
cmap: str | Colormap | None = None,
562562
clim: tuple[float, float] | None = None,
563563
ocean_floor_colour: str = 'black',
564564
landmarks: list[Landmark] | None = None,
@@ -620,7 +620,7 @@ def animate_on_figure(
620620
trim_nans: bool = True,
621621
clamp_to_surface: bool = True,
622622
bathymetry: xarray.DataArray | None = None,
623-
cmap: str | Colormap = 'jet',
623+
cmap: str | Colormap | None = None,
624624
clim: tuple[float, float] | None = None,
625625
ocean_floor_colour: str = 'black',
626626
landmarks: list[Landmark] | None = None,
@@ -717,7 +717,7 @@ def _plot_on_figure(
717717
trim_nans: bool = True,
718718
clamp_to_surface: bool = True,
719719
bathymetry: xarray.DataArray | None = None,
720-
cmap: str | Colormap = 'jet',
720+
cmap: str | Colormap | None = None,
721721
clim: tuple[float, float] | None = None,
722722
ocean_floor_colour: str = 'black',
723723
landmarks: list[Landmark] | None = None,
@@ -774,8 +774,7 @@ def _plot_on_figure(
774774
if title is not None:
775775
axes.set_title(title)
776776

777-
if isinstance(cmap, str):
778-
cmap = colormaps[cmap].copy()
777+
cmap = pyplot.get_cmap(cmap).copy()
779778
cmap.set_bad(ocean_floor_colour)
780779

781780
# Find a min/max from the data if clim isn't provided and the data array is not empty.

0 commit comments

Comments
 (0)