From 8a99a1f3a0183d1994b5f471649f0bd83c7cc840 Mon Sep 17 00:00:00 2001 From: Wei Ji Date: Mon, 21 Sep 2020 10:31:27 +1200 Subject: [PATCH 1/4] Add common alias xshift (X) and yshift (Y) to decorators.py --- pygmt/helpers/decorators.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pygmt/helpers/decorators.py b/pygmt/helpers/decorators.py index 1618d12eea5..8291e5f7844 100644 --- a/pygmt/helpers/decorators.py +++ b/pygmt/helpers/decorators.py @@ -53,6 +53,16 @@ "W": """\ pen : str Set pen attributes for lines or the outline of symbols.""", + "X": """\ + xshift : str + ``[a|c|f|r][xshift]``. + Shift plot origin in x-direction. + """, + "Y": """\ + yshift : str + ``[a|c|f|r]yshift``. + Shift plot origin in y-direction. + """, "j": """\ distcalc : str ``e|f|g``. From 72f9ae2f8afe0d23d652b98c2267e426c68847ef Mon Sep 17 00:00:00 2001 From: Wei Ji Date: Mon, 21 Sep 2020 10:32:07 +1200 Subject: [PATCH 2/4] Add common alias xshift (X) and yshift (Y) to plot --- pygmt/base_plotting.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pygmt/base_plotting.py b/pygmt/base_plotting.py index 950e1b089de..8b4524dfde8 100644 --- a/pygmt/base_plotting.py +++ b/pygmt/base_plotting.py @@ -476,6 +476,8 @@ def grdview(self, grid, **kwargs): l="label", C="cmap", U="timestamp", + X="xshift", + Y="yshift", t="transparency", ) @kwargs_to_strings(R="sequence", i="sequence_comma") @@ -544,6 +546,8 @@ def plot(self, x=None, y=None, data=None, sizes=None, direction=None, **kwargs): quoted lines). {W} {U} + {X} + {Y} label : str Add a legend entry for the symbol or line being plotted. From a911bd312c3ffd7351e913d5b9a26089705087ac Mon Sep 17 00:00:00 2001 From: Wei Ji Date: Mon, 21 Sep 2020 14:17:49 +1200 Subject: [PATCH 3/4] Merge {X} and {Y} into a single {XY} common option Also added link to full documentation of xshift/yshift at https://docs.generic-mapping-tools.org/latest/gmt.html#xy-full --- pygmt/base_plotting.py | 3 +-- pygmt/helpers/decorators.py | 9 ++++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/pygmt/base_plotting.py b/pygmt/base_plotting.py index 1c86a058b5f..a401490d698 100644 --- a/pygmt/base_plotting.py +++ b/pygmt/base_plotting.py @@ -548,8 +548,7 @@ def plot(self, x=None, y=None, data=None, sizes=None, direction=None, **kwargs): quoted lines). {W} {U} - {X} - {Y} + {XY} label : str Add a legend entry for the symbol or line being plotted. diff --git a/pygmt/helpers/decorators.py b/pygmt/helpers/decorators.py index 9c7f773d789..8e460fb0216 100644 --- a/pygmt/helpers/decorators.py +++ b/pygmt/helpers/decorators.py @@ -53,15 +53,14 @@ "W": """\ pen : str Set pen attributes for lines or the outline of symbols.""", - "X": """\ + "XY": """\ xshift : str ``[a|c|f|r][xshift]``. Shift plot origin in x-direction. - """, - "Y": """\ yshift : str - ``[a|c|f|r]yshift``. - Shift plot origin in y-direction. + ``[a|c|f|r][yshift]``. + Shift plot origin in y-direction. Full documentation is at + :gmt-docs:`gmt.html#xy-full`. """, "j": """\ distcalc : str From 854b2e671283ce97d1d6b81533a76328d0c473df Mon Sep 17 00:00:00 2001 From: Wei Ji Date: Mon, 21 Sep 2020 14:58:33 +1200 Subject: [PATCH 4/4] Add xshift/yshift long alias to all plotting functions --- pygmt/base_plotting.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/pygmt/base_plotting.py b/pygmt/base_plotting.py index a401490d698..2ba5bdfdca0 100644 --- a/pygmt/base_plotting.py +++ b/pygmt/base_plotting.py @@ -68,6 +68,8 @@ def _preprocess(self, **kwargs): # pylint: disable=no-self-use G="land", S="water", U="timestamp", + X="xshift", + Y="yshift", t="transparency", ) @kwargs_to_strings(R="sequence") @@ -129,6 +131,7 @@ def coast(self, **kwargs): shorelines : str ``'[level/]pen'`` Draw shorelines [Default is no shorelines]. Append pen attributes. + {XY} {t} """ @@ -146,6 +149,8 @@ def coast(self, **kwargs): F="box", G="truncate", W="scale", + X="xshift", + Y="yshift", t="transparency", ) @kwargs_to_strings(R="sequence", G="sequence") @@ -208,6 +213,7 @@ def colorbar(self, **kwargs): scale : float Multiply all z-values in the CPT by the provided scale. By default the CPT is used as is. + {XY} {t} """ @@ -229,6 +235,8 @@ def colorbar(self, **kwargs): U="timestamp", W="pen", l="label", + X="xshift", + Y="yshift", t="transparency", ) @kwargs_to_strings(R="sequence", L="sequence", A="sequence_plus") @@ -279,6 +287,7 @@ def grdcontour(self, grid, **kwargs): {G} {U} {W} + {XY} label : str Add a legend entry for the contour being plotted. Normally, the annotated contour is selected for the legend. You can select the @@ -309,6 +318,8 @@ def grdcontour(self, grid, **kwargs): B="frame", I="shading", C="cmap", + X="xshift", + Y="yshift", t="transparency", x="cores", ) @@ -327,6 +338,7 @@ def grdimage(self, grid, **kwargs): ---------- grid : str or xarray.DataArray The file name of the input grid or the grid loaded as a DataArray. + {XY} {t} {x} @@ -360,6 +372,8 @@ def grdimage(self, grid, **kwargs): Wf="facadepen", p="perspective", I="shading", + X="xshift", + Y="yshift", t="transparency", ) @kwargs_to_strings(R="sequence", p="sequence") @@ -437,6 +451,7 @@ def grdview(self, grid, **kwargs): intensity, and ambient arguments for that module, or just give ``+d`` to select the default arguments (``+a-45+nt1+m0``). + {XY} {t} """ @@ -602,6 +617,8 @@ def plot(self, x=None, y=None, data=None, sizes=None, direction=None, **kwargs): i="columns", l="label", C="levels", + X="xshift", + Y="yshift", t="transparency", ) @kwargs_to_strings(R="sequence", i="sequence_comma") @@ -660,6 +677,7 @@ def contour(self, x=None, y=None, z=None, data=None, **kwargs): to be of the format [*annotcontlabel*][/*contlabel*]. If either label contains a slash (/) character then use ``|`` as the separator for the two labels instead. + {XY} {t} """ @@ -691,6 +709,8 @@ def contour(self, x=None, y=None, z=None, data=None, **kwargs): Td="rose", Tm="compass", U="timestamp", + X="xshift", + Y="yshift", t="transparency", ) @kwargs_to_strings(R="sequence") @@ -725,6 +745,7 @@ def basemap(self, **kwargs): Draws a map magnetic rose on the map at the location defined by the reference and anchor points {U} + {XY} {t} """ @@ -741,6 +762,8 @@ def basemap(self, **kwargs): U="timestamp", D="position", F="box", + X="xshift", + Y="yshift", t="transparency", ) @kwargs_to_strings(R="sequence") @@ -768,6 +791,7 @@ def logo(self, **kwargs): Without further options, draws a rectangular border around the GMT logo. {U} + {XY} {t} """ @@ -784,6 +808,8 @@ def logo(self, **kwargs): D="position", F="box", M="monochrome", + X="xshift", + Y="yshift", t="transparency", ) @kwargs_to_strings(R="sequence") @@ -819,6 +845,7 @@ def image(self, imagefile, **kwargs): monochrome : bool Convert color image to monochrome grayshades using the (television) YIQ-transformation. + {XY} {t} """ kwargs = self._preprocess(**kwargs) @@ -832,6 +859,8 @@ def image(self, imagefile, **kwargs): J="projection", D="position", F="box", + X="xshift", + Y="yshift", t="transparency", ) @kwargs_to_strings(R="sequence") @@ -868,6 +897,7 @@ def legend(self, spec=None, position="JTR+jTR+o0.2c", box="+gwhite+p1p", **kwarg rectangular border around the legend using **MAP_FRAME_PEN**. By default, uses '+gwhite+p1p' which draws a box around the legend using a 1 point black pen and adds a white background. + {XY} {t} """ kwargs = self._preprocess(**kwargs) @@ -897,6 +927,8 @@ def legend(self, spec=None, position="JTR+jTR+o0.2c", box="+gwhite+p1p", **kwarg D="offset", G="fill", W="pen", + X="xshift", + Y="yshift", t="transparency", ) @kwargs_to_strings( @@ -1003,6 +1035,7 @@ def text( Sets the pen used to draw a rectangle around the text string (see *clearance*) [Default is width = default, color = black, style = solid]. + {XY} {t} """ kwargs = self._preprocess(**kwargs) @@ -1058,6 +1091,8 @@ def text( J="projection", B="frame", C="offset", + X="xshift", + Y="yshift", t="transparency", ) @kwargs_to_strings(R="sequence") @@ -1155,6 +1190,7 @@ def meca( {J} {R} {B} + {XY} {t} """