Skip to content

Commit

Permalink
rename backgroundmap to background everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrakenhoff committed Aug 25, 2023
1 parent 5d52ce2 commit 4fa08c8
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 27 deletions.
12 changes: 9 additions & 3 deletions docs/examples/14_stromingen_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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);"
]
},
{
Expand Down Expand Up @@ -295,7 +295,7 @@
" head.sel(layer=\"PZWAz3\").mean(dim=\"time\"),\n",
" ds,\n",
" alpha=0.25,\n",
" backgroundmap=True,\n",
" background=True,\n",
")"
]
},
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/16_groundwater_transport.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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\")"
]
},
{
Expand Down Expand Up @@ -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",
Expand Down
16 changes: 8 additions & 8 deletions nlmod/plot/flopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def map_array(
colorbar_label="",
plot_grid=False,
add_to_plot=None,
backgroundmap=False,
background=False,
figsize=None,
animate=False,
):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
)
Expand Down
10 changes: 5 additions & 5 deletions nlmod/plot/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def map_array(
plot_grid=True,
rotated=True,
add_to_plot=None,
backgroundmap=False,
background=False,
figsize=None,
animate=False,
):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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,
)
Expand Down
16 changes: 8 additions & 8 deletions nlmod/plot/plotutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def get_map(
sharex=False,
sharey=True,
crs=28992,
backgroundmap=False,
background=False,
alpha=0.5,
tight_layout=True,
):
Expand Down Expand Up @@ -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
Expand All @@ -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")
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_012_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 4fa08c8

Please sign in to comment.