Skip to content

Commit

Permalink
Use transform_first=True for contourf plots with Robinson projection
Browse files Browse the repository at this point in the history
  • Loading branch information
schlunma committed Oct 29, 2024
1 parent f38bbf6 commit 0c59bc2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion esmvaltool/cmorizers/data/formatters/datasets/cmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
from pathlib import Path

import iris
from esmvaltool.cmorizers.data import utilities as utils

from esmvaltool.cmorizers.data import utilities as utils

logger = logging.getLogger(__name__)

Expand Down
6 changes: 6 additions & 0 deletions esmvaltool/diag_scripts/monitor/multi_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1169,6 +1169,9 @@ def _plot_map_with_ref(self, plot_func, dataset, ref_dataset):
# Options used for all subplots
projection = self._get_map_projection()
plot_kwargs = self._get_plot_kwargs(plot_type, dataset)
if plot_func is iris.plot.contourf:
# see https://github.com/SciTools/cartopy/issues/2457
plot_kwargs['transform_first'] = True
gridline_kwargs = self._get_gridline_kwargs(plot_type)
fontsize = self.plots[plot_type]['fontsize']

Expand Down Expand Up @@ -1268,6 +1271,9 @@ def _plot_map_without_ref(self, plot_func, dataset):
axes = fig.add_subplot(projection=self._get_map_projection())
plot_kwargs = self._get_plot_kwargs(plot_type, dataset)
plot_kwargs['axes'] = axes
if plot_func is iris.plot.contourf:
# see https://github.com/SciTools/cartopy/issues/2457
plot_kwargs['transform_first'] = True
plot_map = plot_func(cube, **plot_kwargs)
axes.coastlines()
gridline_kwargs = self._get_gridline_kwargs(plot_type)
Expand Down
1 change: 1 addition & 0 deletions esmvaltool/diag_scripts/shared/plot/_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ def global_contourf(cube,
if cbar_range is not None:
levels = np.linspace(*cbar_range)
kwargs['levels'] = levels
kwargs['transform_first'] = True # see SciTools/cartopy/issues/2457
axes = plt.axes(projection=ccrs.Robinson(central_longitude=10))
plt.sca(axes)
map_plot = iris.plot.contourf(cube, **kwargs)
Expand Down

0 comments on commit 0c59bc2

Please sign in to comment.