Skip to content

Commit faf197e

Browse files
authored
Add common aliases xshift (X) and yshift (Y) (#624)
Used for shifting plots along the x and y dimensions. * 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 * Add xshift/yshift long alias to all plotting functions
1 parent a4d414a commit faf197e

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

pygmt/base_plotting.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ def _preprocess(self, **kwargs): # pylint: disable=no-self-use
6868
G="land",
6969
S="water",
7070
U="timestamp",
71+
X="xshift",
72+
Y="yshift",
7173
t="transparency",
7274
)
7375
@kwargs_to_strings(R="sequence")
@@ -129,6 +131,7 @@ def coast(self, **kwargs):
129131
shorelines : str
130132
``'[level/]pen'``
131133
Draw shorelines [Default is no shorelines]. Append pen attributes.
134+
{XY}
132135
{t}
133136
134137
"""
@@ -146,6 +149,8 @@ def coast(self, **kwargs):
146149
F="box",
147150
G="truncate",
148151
W="scale",
152+
X="xshift",
153+
Y="yshift",
149154
t="transparency",
150155
)
151156
@kwargs_to_strings(R="sequence", G="sequence")
@@ -208,6 +213,7 @@ def colorbar(self, **kwargs):
208213
scale : float
209214
Multiply all z-values in the CPT by the provided scale. By default
210215
the CPT is used as is.
216+
{XY}
211217
{t}
212218
213219
"""
@@ -229,6 +235,8 @@ def colorbar(self, **kwargs):
229235
U="timestamp",
230236
W="pen",
231237
l="label",
238+
X="xshift",
239+
Y="yshift",
232240
t="transparency",
233241
)
234242
@kwargs_to_strings(R="sequence", L="sequence", A="sequence_plus")
@@ -279,6 +287,7 @@ def grdcontour(self, grid, **kwargs):
279287
{G}
280288
{U}
281289
{W}
290+
{XY}
282291
label : str
283292
Add a legend entry for the contour being plotted. Normally, the
284293
annotated contour is selected for the legend. You can select the
@@ -309,6 +318,8 @@ def grdcontour(self, grid, **kwargs):
309318
B="frame",
310319
I="shading",
311320
C="cmap",
321+
X="xshift",
322+
Y="yshift",
312323
t="transparency",
313324
x="cores",
314325
)
@@ -327,6 +338,7 @@ def grdimage(self, grid, **kwargs):
327338
----------
328339
grid : str or xarray.DataArray
329340
The file name of the input grid or the grid loaded as a DataArray.
341+
{XY}
330342
{t}
331343
{x}
332344
@@ -360,6 +372,8 @@ def grdimage(self, grid, **kwargs):
360372
Wf="facadepen",
361373
p="perspective",
362374
I="shading",
375+
X="xshift",
376+
Y="yshift",
363377
t="transparency",
364378
)
365379
@kwargs_to_strings(R="sequence", p="sequence")
@@ -437,6 +451,7 @@ def grdview(self, grid, **kwargs):
437451
intensity, and ambient arguments for that module, or just give
438452
``+d`` to select the default arguments (``+a-45+nt1+m0``).
439453
454+
{XY}
440455
{t}
441456
442457
"""
@@ -478,6 +493,8 @@ def grdview(self, grid, **kwargs):
478493
l="label",
479494
C="cmap",
480495
U="timestamp",
496+
X="xshift",
497+
Y="yshift",
481498
t="transparency",
482499
)
483500
@kwargs_to_strings(R="sequence", i="sequence_comma")
@@ -546,6 +563,7 @@ def plot(self, x=None, y=None, data=None, sizes=None, direction=None, **kwargs):
546563
quoted lines).
547564
{W}
548565
{U}
566+
{XY}
549567
label : str
550568
Add a legend entry for the symbol or line being plotted.
551569
@@ -599,6 +617,8 @@ def plot(self, x=None, y=None, data=None, sizes=None, direction=None, **kwargs):
599617
i="columns",
600618
l="label",
601619
C="levels",
620+
X="xshift",
621+
Y="yshift",
602622
t="transparency",
603623
)
604624
@kwargs_to_strings(R="sequence", i="sequence_comma")
@@ -657,6 +677,7 @@ def contour(self, x=None, y=None, z=None, data=None, **kwargs):
657677
to be of the format [*annotcontlabel*][/*contlabel*]. If either
658678
label contains a slash (/) character then use ``|`` as the
659679
separator for the two labels instead.
680+
{XY}
660681
{t}
661682
662683
"""
@@ -688,6 +709,8 @@ def contour(self, x=None, y=None, z=None, data=None, **kwargs):
688709
Td="rose",
689710
Tm="compass",
690711
U="timestamp",
712+
X="xshift",
713+
Y="yshift",
691714
t="transparency",
692715
)
693716
@kwargs_to_strings(R="sequence")
@@ -722,6 +745,7 @@ def basemap(self, **kwargs):
722745
Draws a map magnetic rose on the map at the location defined by the
723746
reference and anchor points
724747
{U}
748+
{XY}
725749
{t}
726750
727751
"""
@@ -738,6 +762,8 @@ def basemap(self, **kwargs):
738762
U="timestamp",
739763
D="position",
740764
F="box",
765+
X="xshift",
766+
Y="yshift",
741767
t="transparency",
742768
)
743769
@kwargs_to_strings(R="sequence")
@@ -765,6 +791,7 @@ def logo(self, **kwargs):
765791
Without further options, draws a rectangular border around the
766792
GMT logo.
767793
{U}
794+
{XY}
768795
{t}
769796
770797
"""
@@ -781,6 +808,8 @@ def logo(self, **kwargs):
781808
D="position",
782809
F="box",
783810
M="monochrome",
811+
X="xshift",
812+
Y="yshift",
784813
t="transparency",
785814
)
786815
@kwargs_to_strings(R="sequence")
@@ -816,6 +845,7 @@ def image(self, imagefile, **kwargs):
816845
monochrome : bool
817846
Convert color image to monochrome grayshades using the (television)
818847
YIQ-transformation.
848+
{XY}
819849
{t}
820850
"""
821851
kwargs = self._preprocess(**kwargs)
@@ -829,6 +859,8 @@ def image(self, imagefile, **kwargs):
829859
J="projection",
830860
D="position",
831861
F="box",
862+
X="xshift",
863+
Y="yshift",
832864
t="transparency",
833865
)
834866
@kwargs_to_strings(R="sequence")
@@ -865,6 +897,7 @@ def legend(self, spec=None, position="JTR+jTR+o0.2c", box="+gwhite+p1p", **kwarg
865897
rectangular border around the legend using **MAP_FRAME_PEN**. By
866898
default, uses '+gwhite+p1p' which draws a box around the legend
867899
using a 1 point black pen and adds a white background.
900+
{XY}
868901
{t}
869902
"""
870903
kwargs = self._preprocess(**kwargs)
@@ -894,6 +927,8 @@ def legend(self, spec=None, position="JTR+jTR+o0.2c", box="+gwhite+p1p", **kwarg
894927
D="offset",
895928
G="fill",
896929
W="pen",
930+
X="xshift",
931+
Y="yshift",
897932
t="transparency",
898933
)
899934
@kwargs_to_strings(
@@ -1000,6 +1035,7 @@ def text(
10001035
Sets the pen used to draw a rectangle around the text string
10011036
(see *clearance*) [Default is width = default, color = black,
10021037
style = solid].
1038+
{XY}
10031039
{t}
10041040
"""
10051041
kwargs = self._preprocess(**kwargs)
@@ -1055,6 +1091,8 @@ def text(
10551091
J="projection",
10561092
B="frame",
10571093
C="offset",
1094+
X="xshift",
1095+
Y="yshift",
10581096
t="transparency",
10591097
)
10601098
@kwargs_to_strings(R="sequence")
@@ -1152,6 +1190,7 @@ def meca(
11521190
{J}
11531191
{R}
11541192
{B}
1193+
{XY}
11551194
{t}
11561195
"""
11571196

pygmt/helpers/decorators.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@
5353
"W": """\
5454
pen : str
5555
Set pen attributes for lines or the outline of symbols.""",
56+
"XY": """\
57+
xshift : str
58+
``[a|c|f|r][xshift]``.
59+
Shift plot origin in x-direction.
60+
yshift : str
61+
``[a|c|f|r][yshift]``.
62+
Shift plot origin in y-direction. Full documentation is at
63+
:gmt-docs:`gmt.html#xy-full`.
64+
""",
5665
"j": """\
5766
distcalc : str
5867
``e|f|g``.

0 commit comments

Comments
 (0)