Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion continuous-integration/requirements-3.12.txt
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ pytest==9.0.1
# pytest-mpl
pytest-cov==7.0.0
# via emsarray (pyproject.toml)
pytest-mpl==0.17.0
pytest-mpl==0.18.0
# via emsarray (pyproject.toml)
python-dateutil==2.9.0.post0
# via
Expand Down
2 changes: 1 addition & 1 deletion continuous-integration/requirements-3.13.txt
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ pytest==9.0.1
# pytest-mpl
pytest-cov==7.0.0
# via emsarray (pyproject.toml)
pytest-mpl==0.17.0
pytest-mpl==0.18.0
# via emsarray (pyproject.toml)
python-dateutil==2.9.0.post0
# via
Expand Down
2 changes: 1 addition & 1 deletion continuous-integration/requirements-3.14.txt
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ pytest==9.0.1
# pytest-mpl
pytest-cov==7.0.0
# via emsarray (pyproject.toml)
pytest-mpl==0.17.0
pytest-mpl==0.18.0
# via emsarray (pyproject.toml)
python-dateutil==2.9.0.post0
# via
Expand Down
Binary file modified docs/_static/images/gbr4_temp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_static/images/kgari-path.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_static/images/kgari-transect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 9 additions & 6 deletions docs/examples/kgari-transect.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import emsarray
from emsarray import plot, transect

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

Expand Down Expand Up @@ -34,7 +34,9 @@
dataset, line, dataset['temp'],
figsize=(7.9, 3),
bathymetry=dataset['botz'],
landmarks=landmarks)
landmarks=landmarks,
title="Temperature",
cmap='Oranges_r')
figure.savefig('kgari-transect.png')

# Plot the path of the transect
Expand All @@ -43,14 +45,15 @@
axes.set_aspect(aspect='equal', adjustable='datalim')
axes.set_title('Transect path')
axes.add_collection(dataset.ems.make_poly_collection(
dataset['botz'], cmap='Blues_r', edgecolor='face',
dataset['botz'], cmap='Blues', clim=(0, 2000), edgecolor='face',
linewidth=0.5, zorder=0))
axes = figure.axes[0]
axes.set_extent(plot.bounds_to_extent(line.envelope.buffer(0.2).bounds))
axes.plot(*line.coords.xy, zorder=2, c='orange', linewidth=4)

plot.add_coast(axes, zorder=1)
plot.add_gridlines(axes)
plot.add_landmarks(axes, landmarks)
axes = figure.axes[0]
axes.set_extent(plot.bounds_to_extent(line.envelope.buffer(0.2).bounds))
axes.plot(*line.coords.xy, zorder=2)
figure.savefig('kgari-path.png')

pyplot.show(block=True)
4 changes: 4 additions & 0 deletions docs/releases/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ Next release (in development)
which is a backwards incompatible change
but is difficult to add meaningful backwards compatible support
(:issue:`109`, :pr:`204`)
* Use default matplotlib colour map when plotting instead of "jet".
In practice this will usually be "viridis"
unless the user has changed their local defaults
(:pr:`206`).
11 changes: 2 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,6 @@ where = ["src"]
mypkg = ["py.typed"]

[tool.pytest.ini_options]
addopts = [
# TODO Work around till the mpl-baseline-path ini option is included in the
# next pytest-mpl release.
"--mpl-baseline-path", "tests/baseline_images",
]

testpaths = ["tests"]
filterwarnings = [
"error",
Expand All @@ -106,9 +100,8 @@ markers = [
]

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

[tool.mypy]
python_version = "3.12"
Expand Down
6 changes: 3 additions & 3 deletions src/emsarray/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def add_landmarks(
# Plot the temperature
temperature = dataset.ems.make_poly_collection(
dataset['temp'].isel(time=0, k=-1),
cmap='jet', edgecolor='face', zorder=0)
cmap='viridis', edgecolor='face', zorder=0)
axes.add_collection(temperature)
figure.colorbar(temperature, label='°C')

Expand Down Expand Up @@ -321,7 +321,7 @@ def plot_on_figure(
if scalar is not None:
# Plot a scalar variable on the polygons using a colour map
collection = convention.make_poly_collection(
scalar, cmap='jet', edgecolor='face')
scalar, edgecolor='face')
axes.add_collection(collection)
units = scalar.attrs.get('units')
figure.colorbar(collection, ax=axes, location='right', label=units)
Expand Down Expand Up @@ -437,7 +437,7 @@ def animate_on_figure(
# Plot a scalar variable on the polygons using a colour map
scalar_values = convention.ravel(scalar).values[:, convention.mask]
collection = convention.make_poly_collection(
cmap='jet', edgecolor='face',
edgecolor='face',
clim=(numpy.nanmin(scalar_values), numpy.nanmax(scalar_values)))
axes.add_collection(collection)
collection.set_animated(True)
Expand Down
11 changes: 5 additions & 6 deletions src/emsarray/transect.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import shapely
import xarray
from cartopy import crs
from matplotlib import animation, colormaps, pyplot
from matplotlib import animation, pyplot
from matplotlib.artist import Artist
from matplotlib.axes import Axes
from matplotlib.collections import PolyCollection
Expand Down Expand Up @@ -558,7 +558,7 @@ def plot_on_figure(
trim_nans: bool = True,
clamp_to_surface: bool = True,
bathymetry: xarray.DataArray | None = None,
cmap: str | Colormap = 'jet',
cmap: str | Colormap | None = None,
clim: tuple[float, float] | None = None,
ocean_floor_colour: str = 'black',
landmarks: list[Landmark] | None = None,
Expand Down Expand Up @@ -620,7 +620,7 @@ def animate_on_figure(
trim_nans: bool = True,
clamp_to_surface: bool = True,
bathymetry: xarray.DataArray | None = None,
cmap: str | Colormap = 'jet',
cmap: str | Colormap | None = None,
clim: tuple[float, float] | None = None,
ocean_floor_colour: str = 'black',
landmarks: list[Landmark] | None = None,
Expand Down Expand Up @@ -717,7 +717,7 @@ def _plot_on_figure(
trim_nans: bool = True,
clamp_to_surface: bool = True,
bathymetry: xarray.DataArray | None = None,
cmap: str | Colormap = 'jet',
cmap: str | Colormap | None = None,
clim: tuple[float, float] | None = None,
ocean_floor_colour: str = 'black',
landmarks: list[Landmark] | None = None,
Expand Down Expand Up @@ -774,8 +774,7 @@ def _plot_on_figure(
if title is not None:
axes.set_title(title)

if isinstance(cmap, str):
cmap = colormaps[cmap].copy()
cmap = pyplot.get_cmap(cmap).copy()
cmap.set_bad(ocean_floor_colour)

# Find a min/max from the data if clim isn't provided and the data array is not empty.
Expand Down
Binary file modified tests/baseline_images/tests.test_plot.test_plot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/baseline_images/tests.test_transect.test_plot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading