diff --git a/pygmt/src/inset.py b/pygmt/src/inset.py index 3634cd825a8..e05b038c5ac 100644 --- a/pygmt/src/inset.py +++ b/pygmt/src/inset.py @@ -137,8 +137,9 @@ def inset(self, **kwargs): kwargs = self._preprocess(**kwargs) with Session() as lib: try: - lib.call_module(module="inset", args=f"begin {build_arg_list(kwargs)}") + lib.call_module(module="inset", args=["begin", *build_arg_list(kwargs)]) yield finally: - v_arg = build_arg_list({"V": kwargs.get("V")}) - lib.call_module(module="inset", args=f"end {v_arg}".strip()) + lib.call_module( + module="inset", args=["end", *build_arg_list({"V": kwargs.get("V")})] + ) diff --git a/pygmt/src/subplot.py b/pygmt/src/subplot.py index 8f028343948..d4d769f4c21 100644 --- a/pygmt/src/subplot.py +++ b/pygmt/src/subplot.py @@ -160,13 +160,16 @@ def subplot(self, nrows=1, ncols=1, **kwargs): # See https://github.com/GenericMappingTools/pygmt/issues/2426. try: with Session() as lib: - arg_str = " ".join(["begin", f"{nrows}x{ncols}", build_arg_list(kwargs)]) - lib.call_module(module="subplot", args=arg_str) + lib.call_module( + module="subplot", + args=["begin", f"{nrows}x{ncols}", *build_arg_list(kwargs)], + ) yield finally: with Session() as lib: - v_arg = build_arg_list({"V": kwargs.get("V")}) - lib.call_module(module="subplot", args=f"end {v_arg}") + lib.call_module( + module="subplot", args=["end", *build_arg_list({"V": kwargs.get("V")})] + ) @fmt_docstring @@ -224,6 +227,7 @@ def set_panel(self, panel=None, **kwargs): kwargs = self._preprocess(**kwargs) with Session() as lib: - arg_str = " ".join(["set", f"{panel}", build_arg_list(kwargs)]) - lib.call_module(module="subplot", args=arg_str) + lib.call_module( + module="subplot", args=["set", str(panel), *build_arg_list(kwargs)] + ) yield