Skip to content

Fix setting "sharex", "sharey", and "frame" of Figure.subplot in combination with Figure.basemap #2417

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

Merged
merged 25 commits into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9528c3d
Remove setting 'frame' if not given
yvonnefroehlich Mar 13, 2023
389173d
Remove un-needed import of 'args_in_kwargs'
yvonnefroehlich Mar 13, 2023
614dca7
[format-command] fixes
actions-bot Mar 13, 2023
47cb47f
Merge branch 'main' into fix-subplot-frame
yvonnefroehlich Mar 14, 2023
3aa1374
Revert commit c274463
yvonnefroehlich Mar 14, 2023
f431db6
Merge branch 'main' into fix-subplot-frame
yvonnefroehlich Mar 15, 2023
c0a3523
Improve error message (code review)
yvonnefroehlich Mar 15, 2023
6442186
Merge branch 'main' into fix-subplot-frame
yvonnefroehlich Mar 17, 2023
8e9d4e5
Remove check
yvonnefroehlich Mar 18, 2023
3c90376
Merge branch 'main' into fix-subplot-frame
yvonnefroehlich Mar 18, 2023
0ad5c76
Remove un-used import
yvonnefroehlich Mar 18, 2023
75de44d
Fix imports - all in one line
yvonnefroehlich Mar 18, 2023
faf9aca
More precise formulation (code review)
yvonnefroehlich Mar 19, 2023
6065479
Add comma
yvonnefroehlich Mar 19, 2023
37710f1
Remove test 'test_basemap_required_args'
yvonnefroehlich Mar 19, 2023
7285fa5
Remove un-used import
yvonnefroehlich Mar 19, 2023
0716819
Add test
yvonnefroehlich Mar 19, 2023
913b43d
[format-command] fixes
actions-bot Mar 19, 2023
ad44310
Simplify unit test (code review)
yvonnefroehlich Mar 20, 2023
46ef398
Remove un-used variables
yvonnefroehlich Mar 20, 2023
6829489
Merge branch 'main' into fix-subplot-frame
yvonnefroehlich Mar 20, 2023
db256f0
Merge branch 'main' into fix-subplot-frame
yvonnefroehlich Mar 23, 2023
162a354
Merge branch 'main' into fix-subplot-frame
yvonnefroehlich Mar 25, 2023
6fba473
Merge branch 'main' into fix-subplot-frame
yvonnefroehlich Mar 27, 2023
e1ffbdb
Add test_basemap_subplot.png into DVC
Mar 27, 2023
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
13 changes: 4 additions & 9 deletions pygmt/src/basemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@
"""

from pygmt.clib import Session
from pygmt.helpers import (
args_in_kwargs,
build_arg_string,
fmt_docstring,
kwargs_to_strings,
use_alias,
)
from pygmt.helpers import build_arg_string, fmt_docstring, kwargs_to_strings, use_alias


@fmt_docstring
Expand Down Expand Up @@ -39,6 +33,9 @@ def basemap(self, **kwargs):
tick-mark intervals for boundary annotation, ticking, and [optionally]
gridlines. A simple map scale or directional rose may also be plotted.

At least one of the parameters ``frame``, ``map_scale``, ``rose``, or
``compass`` must be specified if not in subplot mode.

Full option list at :gmt-docs:`basemap.html`

{aliases}
Expand Down Expand Up @@ -86,7 +83,5 @@ def basemap(self, **kwargs):
{transparency}
"""
kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access
if not args_in_kwargs(args=["B", "L", "Td", "Tm", "c"], kwargs=kwargs):
kwargs["B"] = True # Plotting frames if required arguments not given
with Session() as lib:
lib.call_module(module="basemap", args=build_arg_string(kwargs))
4 changes: 0 additions & 4 deletions pygmt/tests/baseline/test_basemap_required_args.png.dvc

This file was deleted.

4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_basemap_subplot.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 1b4ae53658eec125ebf8ab4eac78d729
size: 8733
path: test_basemap_subplot.png
25 changes: 15 additions & 10 deletions pygmt/tests/test_basemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,6 @@
from pygmt import Figure


@pytest.mark.mpl_image_compare
def test_basemap_required_args():
"""
Automatically set `frame=True` when required arguments are not given.
"""
fig = Figure()
fig.basemap(region=[10, 70, -3, 8], projection="X8c/6c")
return fig


@pytest.mark.mpl_image_compare
def test_basemap():
"""
Expand Down Expand Up @@ -136,3 +126,18 @@ def test_basemap_map_scale():
map_scale="jMC+c26.5+w10k+f+l",
)
return fig


@pytest.mark.mpl_image_compare
def test_basemap_subplot():
"""
Test in subplot mode for the case that the frame parameter of basemap is
not specified.
"""
fig = Figure()
with fig.subplot(nrows=1, ncols=2, figsize=("10c", "5c")):
with fig.set_panel(panel=0):
fig.basemap(region=[0, 10, 0, 10], projection="X?")
with fig.set_panel(panel=1):
fig.basemap(region=[0, 10, 0, 10], projection="X?")
return fig