From ece3a5aa4942115de6af843ca2bcdcb57fe9a156 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Sun, 4 Oct 2026 14:53:56 +0800 Subject: [PATCH 1/3] Figure.subplot: Add an inline example --- pygmt/src/subplot.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/pygmt/src/subplot.py b/pygmt/src/subplot.py index 58782de6516..1fe800c6fbc 100644 --- a/pygmt/src/subplot.py +++ b/pygmt/src/subplot.py @@ -21,6 +21,8 @@ from pygmt.params import Axis, Box, Frame, Position from pygmt.src._common import _parse_position +__doctest_skip__ = ["subplot"] + def _alias_option_A( # ruff: ignore[invalid-function-name] tag: str | bool = False, @@ -297,6 +299,42 @@ def subplot( $region $frame $verbose + + Examples + -------- + Create a figure with two subplots in one row, showing regional maps of Japan and New + Zealand in the Mercator projection. The subplots are tagged as "a)" and "b)" at the + Top Left corner outside each map frame. The ``?`` in ``projection`` means the width + of each map is automatically determined from the subplot dimensions: + + >>> import pygmt + >>> from pygmt.params import Position + >>> fig = pygmt.Figure() + >>> with fig.subplot( + ... nrows=1, + ... ncols=2, + ... figsize=("15c", "6c"), + ... tag=True, + ... tag_position=Position("TL", cstype="outside"), + ... margins="1c", + ... ): + ... fig.coast( + ... region=[128, 146, 30, 46], + ... projection="M?", + ... land="gray", + ... water="lightblue", + ... frame=True, + ... panel=0, + ... ) + ... fig.coast( + ... region=[165, 180, -48, -34], + ... projection="M?", + ... land="gray", + ... water="lightblue", + ... frame=True, + ... panel=1, + ... ) + >>> fig.show() """ if nrows < 1 or ncols < 1: _value = f"{nrows=}, {ncols=}" From d5d063a769c1ba071b0c8730ef2c759e853fefe7 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Sun, 4 Oct 2026 19:27:06 +0800 Subject: [PATCH 2/3] Apply batched suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Yvonne Fröhlich <94163266+yvonnefroehlich@users.noreply.github.com> --- pygmt/src/subplot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/src/subplot.py b/pygmt/src/subplot.py index 1fe800c6fbc..f7c9d6fed03 100644 --- a/pygmt/src/subplot.py +++ b/pygmt/src/subplot.py @@ -304,7 +304,7 @@ def subplot( -------- Create a figure with two subplots in one row, showing regional maps of Japan and New Zealand in the Mercator projection. The subplots are tagged as "a)" and "b)" at the - Top Left corner outside each map frame. The ``?`` in ``projection`` means the width + Top Left corner outside each map frame. The ``"?"`` in ``projection`` means the width of each map is automatically determined from the subplot dimensions: >>> import pygmt @@ -316,7 +316,7 @@ def subplot( ... figsize=("15c", "6c"), ... tag=True, ... tag_position=Position("TL", cstype="outside"), - ... margins="1c", + ... margins="0.5c", ... ): ... fig.coast( ... region=[128, 146, 30, 46], From fa401e8667d0e531606565a67585d8b851c54713 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Sun, 4 Oct 2026 19:34:50 +0800 Subject: [PATCH 3/3] Fix long line length --- pygmt/src/subplot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/src/subplot.py b/pygmt/src/subplot.py index f7c9d6fed03..99586161d7f 100644 --- a/pygmt/src/subplot.py +++ b/pygmt/src/subplot.py @@ -304,8 +304,8 @@ def subplot( -------- Create a figure with two subplots in one row, showing regional maps of Japan and New Zealand in the Mercator projection. The subplots are tagged as "a)" and "b)" at the - Top Left corner outside each map frame. The ``"?"`` in ``projection`` means the width - of each map is automatically determined from the subplot dimensions: + Top Left corner outside each map frame. The ``"?"`` in ``projection`` means the + width of each map is automatically determined from the subplot dimensions: >>> import pygmt >>> from pygmt.params import Position