Skip to content

Commit 52b899d

Browse files
authored
Merge pull request #206 from csiro-coasts/use-default-cmap
Use matplotlib default colourmap
2 parents c86706e + e44f534 commit 52b899d

File tree

14 files changed

+26
-27
lines changed

14 files changed

+26
-27
lines changed

continuous-integration/requirements-3.12.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ pytest==9.0.1
184184
# pytest-mpl
185185
pytest-cov==7.0.0
186186
# via emsarray (pyproject.toml)
187-
pytest-mpl==0.17.0
187+
pytest-mpl==0.18.0
188188
# via emsarray (pyproject.toml)
189189
python-dateutil==2.9.0.post0
190190
# via

continuous-integration/requirements-3.13.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ pytest==9.0.1
184184
# pytest-mpl
185185
pytest-cov==7.0.0
186186
# via emsarray (pyproject.toml)
187-
pytest-mpl==0.17.0
187+
pytest-mpl==0.18.0
188188
# via emsarray (pyproject.toml)
189189
python-dateutil==2.9.0.post0
190190
# via

continuous-integration/requirements-3.14.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ pytest==9.0.1
184184
# pytest-mpl
185185
pytest-cov==7.0.0
186186
# via emsarray (pyproject.toml)
187-
pytest-mpl==0.17.0
187+
pytest-mpl==0.18.0
188188
# via emsarray (pyproject.toml)
189189
python-dateutil==2.9.0.post0
190190
# via

docs/_static/images/gbr4_temp.png

5.1 KB
Loading

docs/_static/images/kgari-path.png

7.87 KB
Loading
2.76 KB
Loading

docs/examples/kgari-transect.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import emsarray
55
from emsarray import plot, transect
66

7-
dataset_url = 'https://thredds.nci.org.au/thredds/dodsC/fx3/model_data/gbr4_bgc_GBR4_H2p0_B2p0_Chyd_Dcrt.ncml'
7+
dataset_url = 'https://thredds.nci.org.au/thredds/dodsC/fx3/gbr4_H4p0_ABARRAr2_OBRAN2020_FG2Gv3_Dhnd/gbr4_simple_2022-10-31.nc'
88
dataset = emsarray.open_dataset(dataset_url).isel(time=-1)
99
dataset = dataset.ems.select_variables(['botz', 'temp'])
1010

@@ -34,7 +34,9 @@
3434
dataset, line, dataset['temp'],
3535
figsize=(7.9, 3),
3636
bathymetry=dataset['botz'],
37-
landmarks=landmarks)
37+
landmarks=landmarks,
38+
title="Temperature",
39+
cmap='Oranges_r')
3840
figure.savefig('kgari-transect.png')
3941

4042
# Plot the path of the transect
@@ -43,14 +45,15 @@
4345
axes.set_aspect(aspect='equal', adjustable='datalim')
4446
axes.set_title('Transect path')
4547
axes.add_collection(dataset.ems.make_poly_collection(
46-
dataset['botz'], cmap='Blues_r', edgecolor='face',
48+
dataset['botz'], cmap='Blues', clim=(0, 2000), edgecolor='face',
4749
linewidth=0.5, zorder=0))
50+
axes = figure.axes[0]
51+
axes.set_extent(plot.bounds_to_extent(line.envelope.buffer(0.2).bounds))
52+
axes.plot(*line.coords.xy, zorder=2, c='orange', linewidth=4)
53+
4854
plot.add_coast(axes, zorder=1)
4955
plot.add_gridlines(axes)
5056
plot.add_landmarks(axes, landmarks)
51-
axes = figure.axes[0]
52-
axes.set_extent(plot.bounds_to_extent(line.envelope.buffer(0.2).bounds))
53-
axes.plot(*line.coords.xy, zorder=2)
5457
figure.savefig('kgari-path.png')
5558

5659
pyplot.show(block=True)

docs/releases/development.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,7 @@ Next release (in development)
2424
which is a backwards incompatible change
2525
but is difficult to add meaningful backwards compatible support
2626
(:issue:`109`, :pr:`204`)
27+
* Use default matplotlib colour map when plotting instead of "jet".
28+
In practice this will usually be "viridis"
29+
unless the user has changed their local defaults
30+
(:pr:`206`).

pyproject.toml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,6 @@ where = ["src"]
8989
mypkg = ["py.typed"]
9090

9191
[tool.pytest.ini_options]
92-
addopts = [
93-
# TODO Work around till the mpl-baseline-path ini option is included in the
94-
# next pytest-mpl release.
95-
"--mpl-baseline-path", "tests/baseline_images",
96-
]
97-
9892
testpaths = ["tests"]
9993
filterwarnings = [
10094
"error",
@@ -106,9 +100,8 @@ markers = [
106100
]
107101

108102
mpl-use-full-test-name = true
109-
# TODO This option will be included in the next version of pytest-mpl.
110-
# Till then, it is added using addopts above
111-
# mpl-baseline-path = "tests/baseline_images"
103+
mpl-baseline-path = "tests/baseline_images"
104+
mpl-default-style = "default"
112105

113106
[tool.mypy]
114107
python_version = "3.12"

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)

0 commit comments

Comments
 (0)