From df409eea8dd19061a972762ce351dae2e572deb5 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Wed, 12 Nov 2025 17:22:18 +0800 Subject: [PATCH 01/10] Add the parameter 'perspective' as a common parameter to the alias system --- pygmt/alias.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pygmt/alias.py b/pygmt/alias.py index 7e1344c104d..6ab0b130066 100644 --- a/pygmt/alias.py +++ b/pygmt/alias.py @@ -335,6 +335,8 @@ def add_common(self, **kwargs): name="registration", mapping={"gridline": "g", "pixel": "p"}, ) + case "p": + alias = Alias(value, name="perspective", sep="/", size={2, 3}) case "t": alias = Alias(value, name="transparency") case "x": From b1468a6e2a874acaa8cb0a4c6d22402d9df71914 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Wed, 12 Nov 2025 17:23:26 +0800 Subject: [PATCH 02/10] Figure.basemap: Migrate the perspective parameter to the new alias system --- pygmt/src/basemap.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pygmt/src/basemap.py b/pygmt/src/basemap.py index aceed955e1f..627530b0f0a 100644 --- a/pygmt/src/basemap.py +++ b/pygmt/src/basemap.py @@ -7,7 +7,7 @@ from pygmt.alias import AliasSystem from pygmt.clib import Session -from pygmt.helpers import build_arg_list, fmt_docstring, kwargs_to_strings, use_alias +from pygmt.helpers import build_arg_list, fmt_docstring, use_alias @fmt_docstring @@ -19,9 +19,7 @@ Td="rose", Tm="compass", f="coltypes", - p="perspective", ) -@kwargs_to_strings(p="sequence") def basemap( self, projection: str | None = None, @@ -31,6 +29,7 @@ def basemap( | bool = False, panel: int | Sequence[int] | bool = False, transparency: float | None = None, + perspective: float | Sequence[float] | str | bool = False, **kwargs, ): r""" @@ -52,6 +51,7 @@ def basemap( - R = region - V = verbose - c = panel + - p = perspective - t = transparency Parameters @@ -104,6 +104,7 @@ def basemap( R=region, V=verbose, c=panel, + p=perspective, t=transparency, ) aliasdict.merge(kwargs) From 1968f3c127bd98b2687ebd70bccb9d4db7346f24 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Wed, 12 Nov 2025 17:23:42 +0800 Subject: [PATCH 03/10] Improve the docstrings for perspective --- pygmt/helpers/decorators.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/pygmt/helpers/decorators.py b/pygmt/helpers/decorators.py index fa5b6ae2e85..fe64e1f5575 100644 --- a/pygmt/helpers/decorators.py +++ b/pygmt/helpers/decorators.py @@ -262,12 +262,24 @@ pen : str Set pen attributes for lines or the outline of symbols.""", "perspective": r""" - perspective : list or str - [**x**\|\ **y**\|\ **z**]\ *azim*\[/*elev*\[/*zlevel*]]\ - [**+w**\ *lon0*/*lat0*\[/*z0*]][**+v**\ *x0*/*y0*]. - Select perspective view and set the azimuth and elevation angle of - the viewpoint [Default is ``[180, 90]``]. Full documentation is at - :gmt-docs:`gmt.html#perspective-full`.""", + perspective + Select perspective view and set the azimuth and elevation of the viewpoint. + + It can be specified as *azimuth*, (*azimuth*, *elevation*), or + (*azimuth*, *elevation*, *zlevel*), in which, + + - *azimuth*: Azimuth angle of the viewpoint in degrees [Default is 180, + i.e., looking from south to north]. + - *elevation*: Elevation angle of the viewpoint above the horizon [Default + is 90, i.e., looking straight down]. + - *zlevel*: Z-level at which 2-D elements (e.g., the map frame) are drawn. + Only applies when used together with ``zsize``/``zscale``. [Default is at + the bottom of the z-axis]. + + Alternatively, set ``perspective=True`` to use the perspective setting used + in the previous plotting method. Or passing a string with the full GMT + syntax to have more control. See :gmt-docs:`gmt.html#perspective-full` for + details.""", "projection": r""" projection *projcode*\[*projparams*/]\ *width*\|\ *scale*. From 51aaf3e5d48863bd6e196aea15687cfa919a67d8 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Wed, 12 Nov 2025 17:47:46 +0800 Subject: [PATCH 04/10] Improve docstrings --- pygmt/helpers/decorators.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pygmt/helpers/decorators.py b/pygmt/helpers/decorators.py index fe64e1f5575..eb4b549821b 100644 --- a/pygmt/helpers/decorators.py +++ b/pygmt/helpers/decorators.py @@ -265,21 +265,21 @@ perspective Select perspective view and set the azimuth and elevation of the viewpoint. - It can be specified as *azimuth*, (*azimuth*, *elevation*), or - (*azimuth*, *elevation*, *zlevel*), in which, + Accepts a single value or a sequence of two or three values: *azimuth*, + (*azimuth*, *elevation*), or (*azimuth*, *elevation*, *zlevel*). - *azimuth*: Azimuth angle of the viewpoint in degrees [Default is 180, i.e., looking from south to north]. - *elevation*: Elevation angle of the viewpoint above the horizon [Default is 90, i.e., looking straight down]. - *zlevel*: Z-level at which 2-D elements (e.g., the map frame) are drawn. - Only applies when used together with ``zsize``/``zscale``. [Default is at - the bottom of the z-axis]. + Only applies when used together with ``zsize`` or ``zscale``. [Default is + at the bottom of the z-axis]. - Alternatively, set ``perspective=True`` to use the perspective setting used - in the previous plotting method. Or passing a string with the full GMT - syntax to have more control. See :gmt-docs:`gmt.html#perspective-full` for - details.""", + Alternatively, set ``perspective=True`` to reuse the perspective setting + from the previous plotting method, or pass a string following the full + GMT syntax for finer control. See :gmt-docs:`gmt.html#perspective-full` + for details.""", "projection": r""" projection *projcode*\[*projparams*/]\ *width*\|\ *scale*. From d441a70ef7ac48b18d5912e656d11520d19287c4 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Wed, 12 Nov 2025 18:04:49 +0800 Subject: [PATCH 05/10] Update all other wrappers --- pygmt/src/coast.py | 6 +++--- pygmt/src/colorbar.py | 14 +++++--------- pygmt/src/contour.py | 6 ++++-- pygmt/src/grdcontour.py | 6 ++++-- pygmt/src/grdimage.py | 7 ++++--- pygmt/src/grdview.py | 7 ++++--- pygmt/src/histogram.py | 6 ++++-- pygmt/src/image.py | 8 +++++--- pygmt/src/legend.py | 7 ++++--- pygmt/src/logo.py | 7 +++++-- pygmt/src/meca.py | 6 +++--- pygmt/src/plot.py | 6 ++++-- pygmt/src/plot3d.py | 6 ++++-- pygmt/src/rose.py | 6 ++++-- pygmt/src/solar.py | 7 ++++--- pygmt/src/ternary.py | 17 ++++++----------- pygmt/src/text.py | 6 +++--- pygmt/src/tilemap.py | 8 +++++--- pygmt/src/velo.py | 6 ++++-- pygmt/src/wiggle.py | 6 ++++-- 20 files changed, 83 insertions(+), 65 deletions(-) diff --git a/pygmt/src/coast.py b/pygmt/src/coast.py index fa2884c005c..9f54ffcafe0 100644 --- a/pygmt/src/coast.py +++ b/pygmt/src/coast.py @@ -12,7 +12,6 @@ args_in_kwargs, build_arg_list, fmt_docstring, - kwargs_to_strings, use_alias, ) from pygmt.params import Box @@ -31,9 +30,7 @@ N="borders", S="water", W="shorelines", - p="perspective", ) -@kwargs_to_strings(p="sequence") def coast( self, resolution: Literal[ @@ -47,6 +44,7 @@ def coast( | bool = False, panel: int | Sequence[int] | bool = False, transparency: float | None = None, + perspective: float | Sequence[float] | str | bool = False, **kwargs, ): r""" @@ -76,6 +74,7 @@ def coast( - R = region - V = verbose - c = panel + - p = perspective - t = transparency Parameters @@ -229,6 +228,7 @@ def coast( R=region, V=verbose, c=panel, + p=perspective, t=transparency, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/colorbar.py b/pygmt/src/colorbar.py index 93f1b43066c..5cbcfec8da1 100644 --- a/pygmt/src/colorbar.py +++ b/pygmt/src/colorbar.py @@ -15,16 +15,9 @@ @fmt_docstring @use_alias( - C="cmap", - D="position", - G="truncate", - L="equalsize", - Q="log", - W="scale", - Z="zfile", - p="perspective", + C="cmap", D="position", G="truncate", L="equalsize", Q="log", W="scale", Z="zfile" ) -@kwargs_to_strings(G="sequence", I="sequence", p="sequence") +@kwargs_to_strings(G="sequence", I="sequence") def colorbar( self, shading: float | Sequence[float] | bool = False, @@ -36,6 +29,7 @@ def colorbar( | bool = False, panel: int | Sequence[int] | bool = False, transparency: float | None = None, + perspective: float | Sequence[float] | str | bool = False, **kwargs, ): r""" @@ -70,6 +64,7 @@ def colorbar( - R = region - V = verbose - c = panel + - p = perspective - t = transparency Parameters @@ -173,6 +168,7 @@ def colorbar( R=region, V=verbose, c=panel, + p=perspective, t=transparency, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/contour.py b/pygmt/src/contour.py index fcce565012e..b4cd956a90e 100644 --- a/pygmt/src/contour.py +++ b/pygmt/src/contour.py @@ -32,9 +32,8 @@ h="header", i="incols", l="label", - p="perspective", ) -@kwargs_to_strings(i="sequence_comma", p="sequence") +@kwargs_to_strings(i="sequence_comma") def contour( # noqa: PLR0913 self, data: PathLike | TableLike | None = None, @@ -49,6 +48,7 @@ def contour( # noqa: PLR0913 | bool = False, panel: int | Sequence[int] | bool = False, transparency: float | None = None, + perspective: float | Sequence[float] | str | bool = False, **kwargs, ): r""" @@ -68,6 +68,7 @@ def contour( # noqa: PLR0913 - R = region - V = verbose - c = panel + - p = perspective - t = transparency Parameters @@ -171,6 +172,7 @@ def contour( # noqa: PLR0913 R=region, V=verbose, c=panel, + p=perspective, t=transparency, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/grdcontour.py b/pygmt/src/grdcontour.py index f0511ddbcb0..925147e47c0 100644 --- a/pygmt/src/grdcontour.py +++ b/pygmt/src/grdcontour.py @@ -33,9 +33,8 @@ W="pen", l="label", f="coltypes", - p="perspective", ) -@kwargs_to_strings(L="sequence", p="sequence") +@kwargs_to_strings(L="sequence") def grdcontour( self, grid: PathLike | xr.DataArray, @@ -46,6 +45,7 @@ def grdcontour( | bool = False, panel: int | Sequence[int] | bool = False, transparency: float | None = None, + perspective: float | Sequence[float] | str | bool = False, **kwargs, ): r""" @@ -61,6 +61,7 @@ def grdcontour( - R = region - V = verbose - c = panel + - p = perspective - t = transparency Parameters @@ -172,6 +173,7 @@ def grdcontour( R=region, V=verbose, c=panel, + p=perspective, t=transparency, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/grdimage.py b/pygmt/src/grdimage.py index a0d1c52d22d..fdd5dced557 100644 --- a/pygmt/src/grdimage.py +++ b/pygmt/src/grdimage.py @@ -9,7 +9,7 @@ from pygmt._typing import PathLike from pygmt.alias import Alias, AliasSystem from pygmt.clib import Session -from pygmt.helpers import build_arg_list, fmt_docstring, kwargs_to_strings, use_alias +from pygmt.helpers import build_arg_list, fmt_docstring, use_alias __doctest_skip__ = ["grdimage"] @@ -24,9 +24,7 @@ Q="nan_transparent", n="interpolation", f="coltypes", - p="perspective", ) -@kwargs_to_strings(p="sequence") def grdimage( # noqa: PLR0913 self, grid: PathLike | xr.DataArray, @@ -39,6 +37,7 @@ def grdimage( # noqa: PLR0913 | bool = False, panel: int | Sequence[int] | bool = False, transparency: float | None = None, + perspective: float | Sequence[float] | str | bool = False, cores: int | bool = False, **kwargs, ): @@ -83,6 +82,7 @@ def grdimage( # noqa: PLR0913 - R = region - V = verbose - c = panel + - p = perspective - t = transparency - x = cores @@ -187,6 +187,7 @@ def grdimage( # noqa: PLR0913 R=region, V=verbose, c=panel, + p=perspective, t=transparency, x=cores, ) diff --git a/pygmt/src/grdview.py b/pygmt/src/grdview.py index 4214a92a19a..7d78279a236 100644 --- a/pygmt/src/grdview.py +++ b/pygmt/src/grdview.py @@ -9,7 +9,7 @@ from pygmt._typing import PathLike from pygmt.alias import AliasSystem from pygmt.clib import Session -from pygmt.helpers import build_arg_list, fmt_docstring, kwargs_to_strings, use_alias +from pygmt.helpers import build_arg_list, fmt_docstring, use_alias __doctest_skip__ = ["grdview"] @@ -28,9 +28,7 @@ I="shading", f="coltypes", n="interpolation", - p="perspective", ) -@kwargs_to_strings(p="sequence") def grdview( self, grid: PathLike | xr.DataArray, @@ -41,6 +39,7 @@ def grdview( | bool = False, panel: int | Sequence[int] | bool = False, transparency: float | None = None, + perspective: float | Sequence[float] | str | bool = False, **kwargs, ): r""" @@ -60,6 +59,7 @@ def grdview( - R = region - V = verbose - c = panel + - p = perspective - t = transparency Parameters @@ -163,6 +163,7 @@ def grdview( R=region, V=verbose, c=panel, + p=perspective, t=transparency, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/histogram.py b/pygmt/src/histogram.py index 03e4966e91a..4b2d026f11f 100644 --- a/pygmt/src/histogram.py +++ b/pygmt/src/histogram.py @@ -32,10 +32,9 @@ h="header", i="incols", l="label", - p="perspective", w="wrap", ) -@kwargs_to_strings(T="sequence", i="sequence_comma", p="sequence") +@kwargs_to_strings(T="sequence", i="sequence_comma") def histogram( self, data: PathLike | TableLike, @@ -46,6 +45,7 @@ def histogram( | bool = False, panel: int | Sequence[int] | bool = False, transparency: float | None = None, + perspective: float | Sequence[float] | str | bool = False, **kwargs, ): r""" @@ -59,6 +59,7 @@ def histogram( - R = region - V = verbose - c = panel + - p = perspective - t = transparency Parameters @@ -156,6 +157,7 @@ def histogram( R=region, V=verbose, c=panel, + p=perspective, t=transparency, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/image.py b/pygmt/src/image.py index 8580c96426f..24a184812eb 100644 --- a/pygmt/src/image.py +++ b/pygmt/src/image.py @@ -8,13 +8,12 @@ from pygmt._typing import PathLike from pygmt.alias import Alias, AliasSystem from pygmt.clib import Session -from pygmt.helpers import build_arg_list, fmt_docstring, kwargs_to_strings, use_alias +from pygmt.helpers import build_arg_list, fmt_docstring, use_alias from pygmt.params import Box @fmt_docstring -@use_alias(D="position", G="bitcolor", p="perspective") -@kwargs_to_strings(p="sequence") +@use_alias(D="position", G="bitcolor") def image( self, imagefile: PathLike, @@ -26,6 +25,7 @@ def image( | bool = False, panel: int | Sequence[int] | bool = False, transparency: float | None = None, + perspective: float | Sequence[float] | str | bool = False, **kwargs, ): r""" @@ -53,6 +53,7 @@ def image( - R = region - V = verbose - c = panel + - p = perspective - t = transparency Parameters @@ -99,6 +100,7 @@ def image( R=region, V=verbose, c=panel, + p=perspective, t=transparency, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/legend.py b/pygmt/src/legend.py index 911a26de2ee..82dabc72478 100644 --- a/pygmt/src/legend.py +++ b/pygmt/src/legend.py @@ -15,15 +15,13 @@ data_kind, fmt_docstring, is_nonstr_iter, - kwargs_to_strings, use_alias, ) from pygmt.params import Box @fmt_docstring -@use_alias(D="position", p="perspective") -@kwargs_to_strings(p="sequence") +@use_alias(D="position") def legend( self, spec: PathLike | io.StringIO | None = None, @@ -35,6 +33,7 @@ def legend( | bool = False, panel: int | Sequence[int] | bool = False, transparency: float | None = None, + perspective: float | Sequence[float] | str | bool = False, **kwargs, ): r""" @@ -54,6 +53,7 @@ def legend( - R = region - V = verbose - c = panel + - p = perspective - t = transparency Parameters @@ -110,6 +110,7 @@ def legend( R=region, V=verbose, c=panel, + p=perspective, t=transparency, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/logo.py b/pygmt/src/logo.py index 82082c45c72..defdc065eb3 100644 --- a/pygmt/src/logo.py +++ b/pygmt/src/logo.py @@ -7,13 +7,12 @@ from pygmt.alias import Alias, AliasSystem from pygmt.clib import Session -from pygmt.helpers import build_arg_list, fmt_docstring, kwargs_to_strings, use_alias +from pygmt.helpers import build_arg_list, fmt_docstring, use_alias from pygmt.params import Box @fmt_docstring @use_alias(D="position") -@kwargs_to_strings(p="sequence") def logo( self, projection: str | None = None, @@ -24,6 +23,7 @@ def logo( | bool = False, panel: int | Sequence[int] | bool = False, transparency: float | None = None, + perspective: float | Sequence[float] | str | bool = False, **kwargs, ): r""" @@ -43,6 +43,7 @@ def logo( - S = style - V = verbose - c = panel + - p = perspective - t = transparency Parameters @@ -67,6 +68,7 @@ def logo( {verbose} {panel} {transparency} + {perspective} """ self._activate_figure() @@ -80,6 +82,7 @@ def logo( R=region, V=verbose, c=panel, + p=perspective, t=transparency, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/meca.py b/pygmt/src/meca.py index d7ddf89345b..54fb84cac16 100644 --- a/pygmt/src/meca.py +++ b/pygmt/src/meca.py @@ -15,7 +15,6 @@ build_arg_list, data_kind, fmt_docstring, - kwargs_to_strings, use_alias, ) from pygmt.src._common import _FocalMechanismConvention @@ -125,9 +124,7 @@ def _auto_offset(spec) -> bool: L="outline", T="nodal", W="pen", - p="perspective", ) -@kwargs_to_strings(p="sequence") def meca( # noqa: PLR0913 self, spec: PathLike | TableLike, @@ -148,6 +145,7 @@ def meca( # noqa: PLR0913 | bool = False, panel: int | Sequence[int] | bool = False, transparency: float | None = None, + perspective: float | Sequence[float] | str | bool = False, **kwargs, ): r""" @@ -209,6 +207,7 @@ def meca( # noqa: PLR0913 - S = scale/convention/component - V = verbose - c = panel + - p = perspective - t = transparency Parameters @@ -380,6 +379,7 @@ def meca( # noqa: PLR0913 R=region, V=verbose, c=panel, + p=perspective, t=transparency, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/plot.py b/pygmt/src/plot.py index 858a783333b..6fecd648733 100644 --- a/pygmt/src/plot.py +++ b/pygmt/src/plot.py @@ -42,10 +42,9 @@ h="header", i="incols", l="label", - p="perspective", w="wrap", ) -@kwargs_to_strings(i="sequence_comma", p="sequence") +@kwargs_to_strings(i="sequence_comma") def plot( # noqa: PLR0912, PLR0913 self, data: PathLike | TableLike | None = None, @@ -62,6 +61,7 @@ def plot( # noqa: PLR0912, PLR0913 | bool = False, panel: int | Sequence[int] | bool = False, transparency: float | Sequence[float] | bool | None = None, + perspective: float | Sequence[float] | str | bool = False, **kwargs, ): r""" @@ -94,6 +94,7 @@ def plot( # noqa: PLR0912, PLR0913 - R = region - V = verbose - c = panel + - p = perspective - t = transparency Parameters @@ -300,6 +301,7 @@ def plot( # noqa: PLR0912, PLR0913 J=projection, V=verbose, c=panel, + p=perspective, t=transparency, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/plot3d.py b/pygmt/src/plot3d.py index d7c1f270e1e..ac8a08dbb58 100644 --- a/pygmt/src/plot3d.py +++ b/pygmt/src/plot3d.py @@ -43,10 +43,9 @@ h="header", i="incols", l="label", - p="perspective", w="wrap", ) -@kwargs_to_strings(i="sequence_comma", p="sequence") +@kwargs_to_strings(i="sequence_comma") def plot3d( # noqa: PLR0912, PLR0913 self, data: PathLike | TableLike | None = None, @@ -64,6 +63,7 @@ def plot3d( # noqa: PLR0912, PLR0913 | bool = False, panel: int | Sequence[int] | bool = False, transparency: float | Sequence[float] | bool | None = None, + perspective: float | Sequence[float] | str | bool = False, **kwargs, ): r""" @@ -96,6 +96,7 @@ def plot3d( # noqa: PLR0912, PLR0913 - R = region - V = verbose - c = panel + - p = perspective - t = transparency Parameters @@ -279,6 +280,7 @@ def plot3d( # noqa: PLR0912, PLR0913 R=region, V=verbose, c=panel, + p=perspective, t=transparency, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/rose.py b/pygmt/src/rose.py index 4f1fca4b343..f2d4810225c 100644 --- a/pygmt/src/rose.py +++ b/pygmt/src/rose.py @@ -33,10 +33,9 @@ e="find", h="header", i="incols", - p="perspective", w="wrap", ) -@kwargs_to_strings(i="sequence_comma", p="sequence") +@kwargs_to_strings(i="sequence_comma") def rose( self, data: PathLike | TableLike | None = None, @@ -48,6 +47,7 @@ def rose( | bool = False, panel: int | Sequence[int] | bool = False, transparency: float | None = None, + perspective: float | Sequence[float] | str | bool = False, **kwargs, ): """ @@ -70,6 +70,7 @@ def rose( - R = region - V = verbose - c = panel + - p = perspective - t = transparency Parameters @@ -215,6 +216,7 @@ def rose( R=region, V=verbose, c=panel, + p=perspective, t=transparency, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/solar.py b/pygmt/src/solar.py index dc7fd8e3018..4e43f215aac 100644 --- a/pygmt/src/solar.py +++ b/pygmt/src/solar.py @@ -9,14 +9,12 @@ from pygmt.alias import Alias, AliasSystem from pygmt.clib import Session from pygmt.exceptions import GMTValueError -from pygmt.helpers import build_arg_list, fmt_docstring, kwargs_to_strings, use_alias +from pygmt.helpers import build_arg_list, fmt_docstring __doctest_skip__ = ["solar"] @fmt_docstring -@use_alias(p="perspective") -@kwargs_to_strings(p="sequence") def solar( # noqa: PLR0913 self, terminator: Literal["astronomical", "civil", "day_night", "nautical"] = "day_night", @@ -30,6 +28,7 @@ def solar( # noqa: PLR0913 | bool = False, panel: int | Sequence[int] | bool = False, transparency: float | None = None, + perspective: float | Sequence[float] | str | bool = False, **kwargs, ): r""" @@ -50,6 +49,7 @@ def solar( # noqa: PLR0913 - W = pen - c = panel - t = transparency + - p = perspective Parameters ---------- @@ -146,6 +146,7 @@ def solar( # noqa: PLR0913 R=region, V=verbose, c=panel, + p=perspective, t=transparency, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/ternary.py b/pygmt/src/ternary.py index 92a52f197f2..f9b79c0f2be 100644 --- a/pygmt/src/ternary.py +++ b/pygmt/src/ternary.py @@ -8,20 +8,12 @@ from pygmt._typing import PathLike, TableLike from pygmt.alias import Alias, AliasSystem from pygmt.clib import Session -from pygmt.helpers import build_arg_list, fmt_docstring, kwargs_to_strings, use_alias +from pygmt.helpers import build_arg_list, fmt_docstring, use_alias @fmt_docstring -@use_alias( - C="cmap", - G="fill", - JX="width", - S="style", - W="pen", - p="perspective", -) -@kwargs_to_strings(p="sequence") -def ternary( +@use_alias(C="cmap", G="fill", JX="width", S="style", W="pen") +def ternary( # noqa: PLR0913 self, data: PathLike | TableLike, alabel: str | None = None, @@ -33,6 +25,7 @@ def ternary( | bool = False, panel: int | Sequence[int] | bool = False, transparency: float | None = None, + perspective: float | Sequence[float] | str | bool = False, **kwargs, ): r""" @@ -54,6 +47,7 @@ def ternary( - R = region - V = verbose - c = panel + - p = perspective - t = transparency Parameters @@ -103,6 +97,7 @@ def ternary( R=region, V=verbose, c=panel, + p=perspective, t=transparency, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/text.py b/pygmt/src/text.py index 817e26e8d9b..900bda554c9 100644 --- a/pygmt/src/text.py +++ b/pygmt/src/text.py @@ -16,7 +16,6 @@ data_kind, fmt_docstring, is_nonstr_iter, - kwargs_to_strings, non_ascii_to_octal, use_alias, ) @@ -33,10 +32,8 @@ f="coltypes", h="header", it="use_word", - p="perspective", w="wrap", ) -@kwargs_to_strings(p="sequence") def text_( # noqa: PLR0912, PLR0913, PLR0915 self, textfiles: PathLike | TableLike | None = None, @@ -55,6 +52,7 @@ def text_( # noqa: PLR0912, PLR0913, PLR0915 | bool = False, panel: int | Sequence[int] | bool = False, transparency: float | Sequence[float] | bool | None = None, + perspective: float | Sequence[float] | str | bool = False, **kwargs, ): r""" @@ -81,6 +79,7 @@ def text_( # noqa: PLR0912, PLR0913, PLR0915 - R = region - V = verbose - c = panel + - p = perspective - t = transparency Parameters @@ -281,6 +280,7 @@ def text_( # noqa: PLR0912, PLR0913, PLR0915 R=region, V=verbose, c=panel, + p=perspective, t=transparency, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/tilemap.py b/pygmt/src/tilemap.py index e6a2ed4c2cb..d1484f7e410 100644 --- a/pygmt/src/tilemap.py +++ b/pygmt/src/tilemap.py @@ -9,7 +9,7 @@ from pygmt.clib import Session from pygmt.datasets.tile_map import load_tile_map from pygmt.enums import GridType -from pygmt.helpers import build_arg_list, fmt_docstring, kwargs_to_strings, use_alias +from pygmt.helpers import build_arg_list, fmt_docstring, use_alias try: from xyzservices import TileProvider @@ -18,8 +18,7 @@ @fmt_docstring -@use_alias(E="dpi", I="shading", Q="nan_transparent", p="perspective") -@kwargs_to_strings(p="sequence") +@use_alias(E="dpi", I="shading", Q="nan_transparent") def tilemap( # noqa: PLR0913 self, region: Sequence[float], @@ -37,6 +36,7 @@ def tilemap( # noqa: PLR0913 | bool = False, panel: int | Sequence[int] | bool = False, transparency: float | None = None, + perspective: float | Sequence[float] | str | bool = False, **kwargs, ): r""" @@ -59,6 +59,7 @@ def tilemap( # noqa: PLR0913 - N = no_clip - V = verbose - c = panel + - p = perspective - t = transparency Parameters @@ -138,6 +139,7 @@ def tilemap( # noqa: PLR0913 R=region, V=verbose, c=panel, + p=perspective, t=transparency, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/velo.py b/pygmt/src/velo.py index 3771cff41ae..01adc1b22ab 100644 --- a/pygmt/src/velo.py +++ b/pygmt/src/velo.py @@ -31,9 +31,8 @@ e="find", h="header", i="incols", - p="perspective", ) -@kwargs_to_strings(i="sequence_comma", p="sequence") +@kwargs_to_strings(i="sequence_comma") def velo( self, data: PathLike | TableLike | None = None, @@ -45,6 +44,7 @@ def velo( | bool = False, panel: int | Sequence[int] | bool = False, transparency: float | None = None, + perspective: float | Sequence[float] | str | bool = False, **kwargs, ): r""" @@ -68,6 +68,7 @@ def velo( - R = region - V = verbose - c = panel + - p = perspective - t = transparency Parameters @@ -274,6 +275,7 @@ def velo( R=region, V=verbose, c=panel, + p=perspective, t=transparency, ) aliasdict.merge(kwargs) diff --git a/pygmt/src/wiggle.py b/pygmt/src/wiggle.py index f2bb807187b..ec46f1d0e2d 100644 --- a/pygmt/src/wiggle.py +++ b/pygmt/src/wiggle.py @@ -51,10 +51,9 @@ def _parse_fills(fillpositive, fillnegative): g="gap", h="header", i="incols", - p="perspective", w="wrap", ) -@kwargs_to_strings(i="sequence_comma", p="sequence") +@kwargs_to_strings(i="sequence_comma") def wiggle( # noqa: PLR0913 self, data: PathLike | TableLike | None = None, @@ -70,6 +69,7 @@ def wiggle( # noqa: PLR0913 | bool = False, panel: int | Sequence[int] | bool = False, transparency: float | None = None, + perspective: float | Sequence[float] | str | bool = False, **kwargs, ): r""" @@ -89,6 +89,7 @@ def wiggle( # noqa: PLR0913 - R = region - V = verbose - c = panel + - p = perspective - t = transparency Parameters @@ -147,6 +148,7 @@ def wiggle( # noqa: PLR0913 R=region, V=verbose, c=panel, + p=perspective, t=transparency, ) aliasdict.merge(kwargs) From 66d62839381380c65f5f847df1a76dcb3fc86f9e Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Wed, 12 Nov 2025 18:08:10 +0800 Subject: [PATCH 06/10] Figure.solar: the 'aliases' placeholder no longer makes sense --- pygmt/src/solar.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pygmt/src/solar.py b/pygmt/src/solar.py index 4e43f215aac..edfd5688d44 100644 --- a/pygmt/src/solar.py +++ b/pygmt/src/solar.py @@ -39,7 +39,11 @@ def solar( # noqa: PLR0913 Full GMT docs at :gmt-docs:`solar.html`. - {aliases} + **Aliases:** + + .. hlist:: + :columns: 3 + - B = frame - G = fill - J = projection From c27c55ec88c272c3728069aaf0f7d45b912d012e Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Wed, 12 Nov 2025 21:43:47 +0800 Subject: [PATCH 07/10] Update pygmt/helpers/decorators.py 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/helpers/decorators.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/helpers/decorators.py b/pygmt/helpers/decorators.py index eb4b549821b..0804bd19a7c 100644 --- a/pygmt/helpers/decorators.py +++ b/pygmt/helpers/decorators.py @@ -273,7 +273,7 @@ - *elevation*: Elevation angle of the viewpoint above the horizon [Default is 90, i.e., looking straight down]. - *zlevel*: Z-level at which 2-D elements (e.g., the map frame) are drawn. - Only applies when used together with ``zsize`` or ``zscale``. [Default is + Only applied when used together with ``zsize`` or ``zscale``. [Default is at the bottom of the z-axis]. Alternatively, set ``perspective=True`` to reuse the perspective setting From 409df39dc926fc6d0e623e4f3bed10960253aff5 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Thu, 13 Nov 2025 10:57:14 +0800 Subject: [PATCH 08/10] Mention modifiers +v/+w --- pygmt/helpers/decorators.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pygmt/helpers/decorators.py b/pygmt/helpers/decorators.py index 0804bd19a7c..474753959cc 100644 --- a/pygmt/helpers/decorators.py +++ b/pygmt/helpers/decorators.py @@ -278,8 +278,9 @@ Alternatively, set ``perspective=True`` to reuse the perspective setting from the previous plotting method, or pass a string following the full - GMT syntax for finer control. See :gmt-docs:`gmt.html#perspective-full` - for details.""", + GMT syntax for finer control (e.g., adding ``+w`` or ``+v`` modifiers to + select another axis location than the plot origin). See + :gmt-docs:`gmt.html#perspective-full` for details.""", "projection": r""" projection *projcode*\[*projparams*/]\ *width*\|\ *scale*. From 491ed541b7815818ac6b15b47d9573761d8cd826 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Thu, 13 Nov 2025 11:11:04 +0800 Subject: [PATCH 09/10] Fix styling --- pygmt/src/grdview.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/grdview.py b/pygmt/src/grdview.py index 39856a91436..0a62dd4f79e 100644 --- a/pygmt/src/grdview.py +++ b/pygmt/src/grdview.py @@ -27,7 +27,7 @@ f="coltypes", n="interpolation", ) -def grdview( +def grdview( # noqa: PLR0913 self, grid: PathLike | xr.DataArray, projection: str | None = None, From 36582bc8aba58d33b08b53b4880821547d1d9429 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Thu, 13 Nov 2025 11:24:02 +0800 Subject: [PATCH 10/10] Apply suggestions from code review Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- pygmt/helpers/decorators.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/helpers/decorators.py b/pygmt/helpers/decorators.py index 474753959cc..fb6ecdf7645 100644 --- a/pygmt/helpers/decorators.py +++ b/pygmt/helpers/decorators.py @@ -271,7 +271,7 @@ - *azimuth*: Azimuth angle of the viewpoint in degrees [Default is 180, i.e., looking from south to north]. - *elevation*: Elevation angle of the viewpoint above the horizon [Default - is 90, i.e., looking straight down]. + is 90, i.e., looking straight down at nadir]. - *zlevel*: Z-level at which 2-D elements (e.g., the map frame) are drawn. Only applied when used together with ``zsize`` or ``zscale``. [Default is at the bottom of the z-axis]. @@ -279,7 +279,7 @@ Alternatively, set ``perspective=True`` to reuse the perspective setting from the previous plotting method, or pass a string following the full GMT syntax for finer control (e.g., adding ``+w`` or ``+v`` modifiers to - select another axis location than the plot origin). See + select an axis location other than the plot origin). See :gmt-docs:`gmt.html#perspective-full` for details.""", "projection": r""" projection