Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add shapes argument to geo_im_from_array() in climada.util.plot #805

Merged
merged 4 commits into from
Nov 17, 2023
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
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@
* Raphael Portmann
* Nicolas Colombi
* Leonie Villiger
* Kam Lam Yeung
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
8 changes: 6 additions & 2 deletions climada/util/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@
return axes


def geo_im_from_array(array_sub, coord, var_name, title,

Check warning on line 253 in climada/util/plot.py

View check run for this annotation

Jenkins - WCR / Pylint

too-complex

LOW: 'geo_im_from_array' is too complex. The McCabe rating is 15
Raw output
no description found

Check warning on line 253 in climada/util/plot.py

View check run for this annotation

Jenkins - WCR / Pylint

too-many-arguments

LOW: Too many arguments (10/7)
Raw output
Used when a function or method takes too many arguments.

Check warning on line 253 in climada/util/plot.py

View check run for this annotation

Jenkins - WCR / Pylint

too-many-locals

LOW: Too many local variables (38/15)
Raw output
Used when a function or method has too many local variables.

Check warning on line 253 in climada/util/plot.py

View check run for this annotation

Jenkins - WCR / Pylint

too-many-branches

LOW: Too many branches (16/12)
Raw output
Used when a function or method has too many branches, making it hard tofollow.

Check warning on line 253 in climada/util/plot.py

View check run for this annotation

Jenkins - WCR / Pylint

too-many-statements

LOW: Too many statements (54/50)
Raw output
Used when a function or method has too many statements. You should then splitit in smaller functions / methods.
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,

Check warning on line 254 in climada/util/plot.py

View check run for this annotation

Jenkins - WCR / Pylint

line-too-long

LOW: Line too long (107/100)
Raw output
Used when a line is longer than a given number of characters.
**kwargs):
"""Image(s) plot defined in array(s) over input coordinates.

Expand All @@ -272,6 +272,9 @@
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
Comment on lines +275 to +277
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would call this coastlines instead of shapes. Much clearer.

Copy link
Collaborator Author

@yklpaul0902 yklpaul0902 Nov 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since other functioms like geo_bin_from_array(), geo_scatter_from_array(), etc, they all name them as shapes for turning on/off the plotting of coastline, I would suggest either having it as shapes in geo_im_from_array(), or renaming all relevant shapes as coastlines, to make it more consistent.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, let it be shapes then. It is a very bad name, but consistency of code is probably more important.

axes : Axes or ndarray(Axes), optional
by default None
figsize : tuple, optional
Expand Down Expand Up @@ -349,7 +352,8 @@
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)
Expand Down