From 158b1d852dc135ec2110964bb0510c5126e6ab48 Mon Sep 17 00:00:00 2001 From: Kam Lam Yeung <70527428+yklpaul0902@users.noreply.github.com> Date: Fri, 17 Nov 2023 08:30:26 +0100 Subject: [PATCH] Add shapes argument to geo_im_from_array() in climada.util.plot (#805) * Add shapes arguement to geo_im_from_array() to enable flexible turn on/off coastline * add author in AUTHORS.md * add changes to CHANGELOG.md * changelog: moved 805 from added to changed --------- Co-authored-by: emanuel-schmid --- AUTHORS.md | 1 + CHANGELOG.md | 1 + climada/util/plot.py | 8 ++++++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/AUTHORS.md b/AUTHORS.md index d5fe7f239..a45b407f7 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -29,3 +29,4 @@ * Raphael Portmann * Nicolas Colombi * Leonie Villiger +* Kam Lam Yeung diff --git a/CHANGELOG.md b/CHANGELOG.md index 212cf9638..7e657dccf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ Code freeze date: YYYY-MM-DD ### Changed +- Add `shapes` argument to `geo_im_from_array` to allow flexible turning on/off of plotting coastline in `plot_intensity`. [#805](https://github.com/CLIMADA-project/climada_python/pull/805) - Update `CONTRIBUTING.md` to better explain types of contributions to this repository [#797](https://github.com/CLIMADA-project/climada_python/pull/797) - The default tile layer in Exposures maps is not Stamen Terrain anymore, but [CartoDB Positron](https://github.com/CartoDB/basemap-styles). Affected methods are `climada.engine.Impact.plot_basemap_eai_exposure`,`climada.engine.Impact.plot_basemap_impact_exposure` and `climada.entity.Exposures.plot_basemap`. [#798](https://github.com/CLIMADA-project/climada_python/pull/798) diff --git a/climada/util/plot.py b/climada/util/plot.py index b35569f28..6573d4793 100644 --- a/climada/util/plot.py +++ b/climada/util/plot.py @@ -251,7 +251,7 @@ def _plot_scattered_data(method, array_sub, geo_coord, var_name, title, def geo_im_from_array(array_sub, coord, var_name, title, - proj=None, smooth=True, axes=None, figsize=(9, 13), adapt_fontsize=True, + proj=None, smooth=True, shapes=True, axes=None, figsize=(9, 13), adapt_fontsize=True, **kwargs): """Image(s) plot defined in array(s) over input coordinates. @@ -272,6 +272,9 @@ def geo_im_from_array(array_sub, coord, var_name, title, coordinate reference system used in coordinates, by default None smooth : bool, optional smooth plot to RESOLUTIONxRESOLUTION, by default True + shapes : bool, optional + Overlay Earth's countries coastlines to matplotlib.pyplot axis. + The default is True axes : Axes or ndarray(Axes), optional by default None figsize : tuple, optional @@ -349,7 +352,8 @@ def geo_im_from_array(array_sub, coord, var_name, title, extent[2], extent[3]), crs=proj) # Add coastline to axis - add_shapes(axis) + if shapes: + add_shapes(axis) # Create colormesh, colorbar and labels in axis cbax = make_axes_locatable(axis).append_axes('right', size="6.5%", pad=0.1, axes_class=plt.Axes)