From 4fa08c8005f452d0b2942ca51be47b23ba3a29c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dav=C3=ADd=20Brakenhoff?= Date: Fri, 25 Aug 2023 10:49:16 +0200 Subject: [PATCH] rename backgroundmap to background everywhere --- docs/examples/14_stromingen_example.ipynb | 12 +++++++++--- docs/examples/16_groundwater_transport.ipynb | 4 ++-- nlmod/plot/flopy.py | 16 ++++++++-------- nlmod/plot/plot.py | 10 +++++----- nlmod/plot/plotutil.py | 16 ++++++++-------- tests/test_012_plot.py | 2 +- 6 files changed, 33 insertions(+), 27 deletions(-) diff --git a/docs/examples/14_stromingen_example.ipynb b/docs/examples/14_stromingen_example.ipynb index 7b825a83..b7098431 100644 --- a/docs/examples/14_stromingen_example.ipynb +++ b/docs/examples/14_stromingen_example.ipynb @@ -68,7 +68,7 @@ "outputs": [], "source": [ "# where in the world are we?\n", - "nlmod.plot.get_map(extent, backgroundmap=True);" + "nlmod.plot.get_map(extent, background=True);" ] }, { @@ -295,7 +295,7 @@ " head.sel(layer=\"PZWAz3\").mean(dim=\"time\"),\n", " ds,\n", " alpha=0.25,\n", - " backgroundmap=True,\n", + " background=True,\n", ")" ] }, @@ -330,8 +330,14 @@ } ], "metadata": { + "kernelspec": { + "display_name": "artesia", + "language": "python", + "name": "python3" + }, "language_info": { - "name": "python" + "name": "python", + "version": "3.10.12" } }, "nbformat": 4, diff --git a/docs/examples/16_groundwater_transport.ipynb b/docs/examples/16_groundwater_transport.ipynb index 123908c5..e3828855 100644 --- a/docs/examples/16_groundwater_transport.ipynb +++ b/docs/examples/16_groundwater_transport.ipynb @@ -83,7 +83,7 @@ "metadata": {}, "outputs": [], "source": [ - "fig, ax = nlmod.plot.get_map(extent_hbossche, backgroundmap=\"OpenStreetMap.Mapnik\")" + "fig, ax = nlmod.plot.get_map(extent_hbossche, background=\"OpenStreetMap.Mapnik\")" ] }, { @@ -488,7 +488,7 @@ "outputs": [], "source": [ "# plot using flopy\n", - "fig, ax = nlmod.plot.get_map(extent_hbossche, backgroundmap=\"OpenStreetMap.Mapnik\")\n", + "fig, ax = nlmod.plot.get_map(extent_hbossche, background=\"OpenStreetMap.Mapnik\")\n", "pmv = fp.plot.PlotMapView(model=gwf, layer=0, ax=ax)\n", "# pc = pmv.plot_array(c.isel(time=0), cmap=\"Spectral_r\")\n", "pmv.plot_bc(\"GHB\", plotAll=True, alpha=0.1, label=\"GHB\")\n", diff --git a/nlmod/plot/flopy.py b/nlmod/plot/flopy.py index b3934734..a3ad93f2 100644 --- a/nlmod/plot/flopy.py +++ b/nlmod/plot/flopy.py @@ -51,7 +51,7 @@ def map_array( colorbar_label="", plot_grid=False, add_to_plot=None, - backgroundmap=False, + background=False, figsize=None, animate=False, ): @@ -96,7 +96,7 @@ def map_array( tuple or list of plotting functions that take ax as the only argument, by default None. Use to add features to plot, e.g. plotting shapefiles, or other data. - backgroundmap : bool, optional + background : bool, optional add background map, by default False figsize : tuple, optional figure size, by default None @@ -135,7 +135,7 @@ def map_array( qm = pmv.plot_array(arr, cmap=cmap, norm=norm, alpha=alpha) # bgmap - if backgroundmap: + if background: add_background_map(ax, map_provider="nlmaps.water", alpha=0.5) # add other info to plot @@ -183,7 +183,7 @@ def contour_array( label_kwargs=None, plot_grid=False, add_to_plot=None, - backgroundmap=False, + background=False, figsize=None, animate=False, **kwargs, @@ -226,7 +226,7 @@ def contour_array( tuple or list of plotting functions that take ax as the only argument, by default None. Use to add features to plot, e.g. plotting shapefiles, or other data. - backgroundmap : bool, optional + background : bool, optional add background map, by default False figsize : tuple, optional figure size, by default None @@ -265,7 +265,7 @@ def contour_array( ax.clabel(cs, **label_kwargs) # bgmap - if backgroundmap: + if background: add_background_map(ax, map_provider="nlmaps.water", alpha=0.5) # add other info to plot @@ -309,7 +309,7 @@ def animate_map( colorbar_label="", plot_grid=True, add_to_plot=None, - backgroundmap=False, + background=False, figsize=(9.24, 10.042), save=False, fname=None, @@ -347,7 +347,7 @@ def animate_map( colorbar_label=colorbar_label, plot_grid=plot_grid, add_to_plot=add_to_plot, - backgroundmap=backgroundmap, + background=background, figsize=figsize, animate=True, ) diff --git a/nlmod/plot/plot.py b/nlmod/plot/plot.py index b0353e76..9af3acb9 100644 --- a/nlmod/plot/plot.py +++ b/nlmod/plot/plot.py @@ -328,7 +328,7 @@ def map_array( plot_grid=True, rotated=True, add_to_plot=None, - backgroundmap=False, + background=False, figsize=None, animate=False, ): @@ -387,7 +387,7 @@ def map_array( ax.axis(extent) # bgmap - if backgroundmap: + if background: add_background_map(ax, map_provider="nlmaps.water", alpha=0.5) # add other info to plot @@ -444,7 +444,7 @@ def animate_map( colorbar_label="", plot_grid=True, rotated=True, - backgroundmap=False, + background=False, figsize=None, ax=None, add_to_plot=None, @@ -491,7 +491,7 @@ def animate_map( Whether to plot the model grid. Default is True. rotated : bool, optional Whether to plot rotated model, if applicable. Default is True. - backgroundmap : bool, optional + background : bool, optional Whether to add a background map. Default is False. figsize : tuple, optional figure size in inches, default is None. @@ -553,7 +553,7 @@ def animate_map( plot_grid=plot_grid, rotated=rotated, add_to_plot=add_to_plot, - backgroundmap=backgroundmap, + background=background, figsize=figsize, animate=True, ) diff --git a/nlmod/plot/plotutil.py b/nlmod/plot/plotutil.py index a32fff00..47778ab4 100644 --- a/nlmod/plot/plotutil.py +++ b/nlmod/plot/plotutil.py @@ -89,7 +89,7 @@ def get_map( sharex=False, sharey=True, crs=28992, - backgroundmap=False, + background=False, alpha=0.5, tight_layout=True, ): @@ -118,11 +118,11 @@ def get_map( sharey : bool, optional Only display the ticks on the left y-axes, when ncols > 1. The default is True. - backgroundmap : bool or str, optional - Draw a background using contextily when True or when background is a string. + background : bool or str, optional + Draw a background map using contextily when True or when background is a string. When background is a string it repesents the map-provider. Use nlmod.plot._list_contextily_providers().keys() to show possible map-providers. - THe defaults is False. + The defaults is False. alpha: float, optional The alpha value of the background. The default is 0.5. tight_layout : bool, optional @@ -143,8 +143,8 @@ def get_map( f, axes = plt.subplots( figsize=figsize, nrows=nrows, ncols=ncols, sharex=sharex, sharey=sharey ) - if isinstance(backgroundmap, bool) and backgroundmap is True: - backgroundmap = "nlmaps.standaard" + if isinstance(background, bool) and background is True: + background = "nlmaps.standaard" def set_ax_in_map(ax): ax.axis("scaled") @@ -155,8 +155,8 @@ def set_ax_in_map(ax): ax.set_yticks([]) else: rd_ticks(ax, base=base, fmt=fmt, fmt_base=fmt_base) - if backgroundmap: - add_background_map(ax, crs=crs, map_provider=backgroundmap, alpha=alpha) + if background: + add_background_map(ax, crs=crs, map_provider=background, alpha=alpha) if nrows == 1 and ncols == 1: set_ax_in_map(axes) diff --git a/tests/test_012_plot.py b/tests/test_012_plot.py index e139ce4c..23d14271 100644 --- a/tests/test_012_plot.py +++ b/tests/test_012_plot.py @@ -28,4 +28,4 @@ def test_plot_data_array_vertex(): def test_plot_get_map(): - nlmod.plot.get_map([100000, 101000, 400000, 401000], backgroundmap=True, figsize=3) + nlmod.plot.get_map([100000, 101000, 400000, 401000], background=True, figsize=3)