diff --git a/examples/gallery/3d_plots/scatter3d.py b/examples/gallery/3d_plots/scatter3d.py index 73a046aba35..1790cbbc02b 100644 --- a/examples/gallery/3d_plots/scatter3d.py +++ b/examples/gallery/3d_plots/scatter3d.py @@ -90,7 +90,9 @@ zscale=1.5, ) +# Shift plot origin in x direction +fig.shift_origin(xshift=3.1) # Add colorbar legend -fig.colorbar(xshift=3.1) +fig.colorbar() fig.show() diff --git a/pygmt/helpers/decorators.py b/pygmt/helpers/decorators.py index d50de3c8733..751adf6aa02 100644 --- a/pygmt/helpers/decorators.py +++ b/pygmt/helpers/decorators.py @@ -97,15 +97,6 @@ "pen": """\ pen : str Set pen attributes for lines or the outline of symbols.""", - "xyshift": r""" - xshift : str - [**a**\|\ **c**\|\ **f**\|\ **r**\][*xshift*]. - Shift plot origin in x-direction. - yshift : str - [**a**\|\ **c**\|\ **f**\|\ **r**\][*yshift*]. - Shift plot origin in y-direction. Full documentation is at - :gmt-docs:`gmt.html#xy-full`. - """, "aspatial": r""" aspatial : bool or str [*col*\ =]\ *name*\ [,...]. @@ -577,6 +568,29 @@ def new_module(*args, **kwargs): f"Use long-form parameter '{long_alias}' instead." ) warnings.warn(msg, category=SyntaxWarning, stacklevel=2) + + # xshift (X) is deprecated since v0.8.0. + if "X" in kwargs or "xshift" in kwargs: + if "xshift" in kwargs: + kwargs["X"] = kwargs.pop("xshift") + msg = ( + "Parameters 'X' and 'xshift' are deprecated since v0.8.0 " + "and will be removed in v0.12.0. " + "Use Figure.shift_origin(xshift=...) instead." + ) + warnings.warn(msg, category=SyntaxWarning, stacklevel=2) + + # yshift (Y) is deprecated since v0.8.0. + if "Y" in kwargs or "yshift" in kwargs: + if "yshift" in kwargs: + kwargs["Y"] = kwargs.pop("yshift") + msg = ( + "Parameters 'Y' and 'yshift' are deprecated since v0.8.0. " + "and will be removed in v0.12.0. " + "Use Figure.shift_origin(yshift=...) instead." + ) + warnings.warn(msg, category=SyntaxWarning, stacklevel=2) + return module_func(*args, **kwargs) new_module.aliases = aliases diff --git a/pygmt/src/basemap.py b/pygmt/src/basemap.py index da7319a835c..9cf4546a696 100644 --- a/pygmt/src/basemap.py +++ b/pygmt/src/basemap.py @@ -25,8 +25,6 @@ Tm="compass", U="timestamp", V="verbose", - X="xshift", - Y="yshift", c="panel", f="coltypes", p="perspective", @@ -84,7 +82,6 @@ def basemap(self, **kwargs): reference and anchor points {timestamp} {verbose} - {xyshift} {panel} {coltypes} {perspective} diff --git a/pygmt/src/coast.py b/pygmt/src/coast.py index ce869689e1a..5c727d61529 100644 --- a/pygmt/src/coast.py +++ b/pygmt/src/coast.py @@ -32,8 +32,6 @@ S="water", U="timestamp", V="verbose", - X="xshift", - Y="yshift", c="panel", p="perspective", t="transparency", @@ -177,7 +175,6 @@ def coast(self, **kwargs): [Default is no fill]. Append **+l**\|\ **+L** to =\ *continent* to only list countries in that continent; repeat if more than one continent is requested. - {xyshift} {panel} {perspective} {transparency} diff --git a/pygmt/src/colorbar.py b/pygmt/src/colorbar.py index c9f1e811714..21224e13775 100644 --- a/pygmt/src/colorbar.py +++ b/pygmt/src/colorbar.py @@ -18,8 +18,6 @@ I="shading", W="scale", V="verbose", - X="xshift", - Y="yshift", c="panel", p="perspective", t="transparency", @@ -100,7 +98,6 @@ def colorbar(self, **kwargs): asymmetric intensity range from *low* to *high*. [Default is no illumination]. {verbose} - {xyshift} {panel} {perspective} {transparency} diff --git a/pygmt/src/contour.py b/pygmt/src/contour.py index 0e7140889ef..9bc707d6e6f 100644 --- a/pygmt/src/contour.py +++ b/pygmt/src/contour.py @@ -20,8 +20,6 @@ U="timestamp", V="verbose", W="pen", - X="xshift", - Y="yshift", b="binary", c="panel", d="nodata", @@ -106,7 +104,6 @@ def contour(self, data=None, x=None, y=None, z=None, **kwargs): separator for the two labels instead. {timestamp} {verbose} - {xyshift} {binary} {panel} {nodata} diff --git a/pygmt/src/grdcontour.py b/pygmt/src/grdcontour.py index 5e44a823ce4..96aa4e913aa 100644 --- a/pygmt/src/grdcontour.py +++ b/pygmt/src/grdcontour.py @@ -22,8 +22,6 @@ V="verbose", W="pen", l="label", - X="xshift", - Y="yshift", c="panel", f="coltypes", p="perspective", @@ -85,7 +83,6 @@ def grdcontour(self, grid, **kwargs): {timestamp} {verbose} {pen} - {xyshift} {panel} {coltypes} label : str diff --git a/pygmt/src/grdimage.py b/pygmt/src/grdimage.py index 17378684886..3b5afdfcd79 100644 --- a/pygmt/src/grdimage.py +++ b/pygmt/src/grdimage.py @@ -31,8 +31,6 @@ R="region", U="timestamp", V="verbose", - X="xshift", - Y="yshift", n="interpolation", c="panel", f="coltypes", @@ -156,7 +154,6 @@ def grdimage(self, grid, **kwargs): 3). {region} {verbose} - {xyshift} {panel} {coltypes} {interpolation} diff --git a/pygmt/src/grdview.py b/pygmt/src/grdview.py index 335f3e5317e..9f9d932e90e 100644 --- a/pygmt/src/grdview.py +++ b/pygmt/src/grdview.py @@ -30,8 +30,6 @@ Wf="facadepen", I="shading", V="verbose", - X="xshift", - Y="yshift", c="panel", f="coltypes", n="interpolation", @@ -114,7 +112,6 @@ def grdview(self, grid, **kwargs): or just give **+d** to select the default arguments [Default is **+a**\ -45\ **+nt**\ 1\ **+m**\ 0]. {verbose} - {xyshift} {panel} {coltypes} {interpolation} diff --git a/pygmt/src/histogram.py b/pygmt/src/histogram.py index 51968acc2ad..4d62beae193 100644 --- a/pygmt/src/histogram.py +++ b/pygmt/src/histogram.py @@ -24,8 +24,6 @@ U="timestamp", V="verbose", W="pen", - X="xshift", - Y="yshift", Z="histtype", b="binary", c="panel", @@ -124,7 +122,6 @@ def histogram(self, data, **kwargs): To use weights provided as a second data column instead of pure counts, append **+w**. - {xyshift} {timestamp} {verbose} {binary} diff --git a/pygmt/src/image.py b/pygmt/src/image.py index f5952d36785..f6840deaac8 100644 --- a/pygmt/src/image.py +++ b/pygmt/src/image.py @@ -14,8 +14,6 @@ M="monochrome", U="timestamp", V="verbose", - X="xshift", - Y="yshift", c="panel", p="perspective", t="transparency", @@ -57,7 +55,6 @@ def image(self, imagefile, **kwargs): YIQ-transformation. {timestamp} {verbose} - {xyshift} {panel} {perspective} {transparency} diff --git a/pygmt/src/legend.py b/pygmt/src/legend.py index e783063e9da..1d4551f0b5e 100644 --- a/pygmt/src/legend.py +++ b/pygmt/src/legend.py @@ -21,8 +21,6 @@ F="box", U="timestamp", V="verbose", - X="xshift", - Y="yshift", c="panel", p="perspective", t="transparency", @@ -67,7 +65,6 @@ def legend(self, spec=None, position="JTR+jTR+o0.2c", box="+gwhite+p1p", **kwarg 1p black pen and adds a white background. {timestamp} {verbose} - {xyshift} {panel} {perspective} {transparency} diff --git a/pygmt/src/logo.py b/pygmt/src/logo.py index afae0536b10..e84e1bc83cb 100644 --- a/pygmt/src/logo.py +++ b/pygmt/src/logo.py @@ -15,8 +15,6 @@ S="style", U="timestamp", V="verbose", - X="xshift", - Y="yshift", c="panel", t="transparency", ) @@ -55,7 +53,6 @@ def logo(self, **kwargs): - **u** to place the URL to the GMT site {timestamp} {verbose} - {xyshift} {panel} {transparency} """ diff --git a/pygmt/src/meca.py b/pygmt/src/meca.py index 948127a2253..86708730cde 100644 --- a/pygmt/src/meca.py +++ b/pygmt/src/meca.py @@ -81,8 +81,6 @@ def data_format_code(convention, component="full"): B="frame", N="no_clip", V="verbose", - X="xshift", - Y="yshift", c="panel", p="perspective", t="transparency", @@ -220,7 +218,6 @@ def meca( {region} {frame} {verbose} - {xyshift} {panel} {perspective} {transparency} diff --git a/pygmt/src/plot.py b/pygmt/src/plot.py index bc3738bce57..df7d489d616 100644 --- a/pygmt/src/plot.py +++ b/pygmt/src/plot.py @@ -34,8 +34,6 @@ U="timestamp", V="verbose", W="pen", - X="xshift", - Y="yshift", Z="zvalue", a="aspatial", b="binary", @@ -187,7 +185,6 @@ def plot(self, data=None, x=None, y=None, size=None, direction=None, **kwargs): {pen} {timestamp} {verbose} - {xyshift} zvalue : str *value*\|\ *file*. Instead of specifying a symbol or polygon fill and outline color diff --git a/pygmt/src/plot3d.py b/pygmt/src/plot3d.py index 07426e6463a..da416fd6ede 100644 --- a/pygmt/src/plot3d.py +++ b/pygmt/src/plot3d.py @@ -34,8 +34,6 @@ S="style", V="verbose", W="pen", - X="xshift", - Y="yshift", Z="zvalue", a="aspatial", b="binary", @@ -156,7 +154,6 @@ def plot3d( {timestamp} {verbose} {pen} - {xyshift} zvalue : str *value*\|\ *file*. Instead of specifying a symbol or polygon fill and outline color diff --git a/pygmt/src/rose.py b/pygmt/src/rose.py index dc82f6659e6..b36b5d5ca1e 100644 --- a/pygmt/src/rose.py +++ b/pygmt/src/rose.py @@ -33,8 +33,6 @@ U="timestamp", V="verbose", W="pen", - X="xshift", - Y="yshift", Z="scale", b="binary", d="nodata", @@ -193,7 +191,6 @@ def rose(self, data=None, length=None, azimuth=None, **kwargs): {timestamp} {verbose} - {xyshift} {binary} {panel} {nodata} diff --git a/pygmt/src/solar.py b/pygmt/src/solar.py index 79d9a31064b..86c6194630b 100644 --- a/pygmt/src/solar.py +++ b/pygmt/src/solar.py @@ -18,8 +18,6 @@ U="timestamp", V="verbose", W="pen", - X="xshift", - Y="yshift", c="panel", p="perspective", t="transparency", @@ -60,7 +58,6 @@ def solar(self, terminator="d", terminator_datetime=None, **kwargs): Set pen attributes for lines [Default is ``"0.25p,black,solid"``]. {timestamp} {verbose} - {xyshift} {panel} {perspective} {transparency} diff --git a/pygmt/src/subplot.py b/pygmt/src/subplot.py index 828b38e11d6..9ef8f7ff9a4 100644 --- a/pygmt/src/subplot.py +++ b/pygmt/src/subplot.py @@ -29,8 +29,6 @@ SR="sharey", T="title", V="verbose", - X="xshift", - Y="yshift", ) @kwargs_to_strings(Ff="sequence", Fs="sequence", M="sequence", R="sequence") def subplot(self, nrows=1, ncols=1, **kwargs): @@ -146,7 +144,6 @@ def subplot(self, nrows=1, ncols=1, **kwargs): ``frame``), the entire figure may also have an overarching *heading* [no heading]. Font is determined by setting :gmt-term:`FONT_HEADING`. {verbose} - {xyshift} """ kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access diff --git a/pygmt/src/ternary.py b/pygmt/src/ternary.py index b357289fe4c..297f0b99a6d 100644 --- a/pygmt/src/ternary.py +++ b/pygmt/src/ternary.py @@ -16,8 +16,6 @@ U="timestamp", V="verbose", W="pen", - X="xshift", - Y="yshift", c="panel", p="perspective", t="transparency", @@ -66,7 +64,6 @@ def ternary(self, data, alabel=None, blabel=None, clabel=None, **kwargs): *symbol*\[\ *size*]. Plot individual symbols in a ternary diagram. {pen} - {xyshift} {timestamp} {verbose} {panel} diff --git a/pygmt/src/text.py b/pygmt/src/text.py index 30b67444960..5e869e466f4 100644 --- a/pygmt/src/text.py +++ b/pygmt/src/text.py @@ -28,8 +28,6 @@ U="timestamp", V="verbose", W="pen", - X="xshift", - Y="yshift", a="aspatial", c="panel", e="find", @@ -153,7 +151,6 @@ def text_( Do NOT clip text at map boundaries [Default is with clip]. {timestamp} {verbose} - {xyshift} {aspatial} {panel} {find} diff --git a/pygmt/src/velo.py b/pygmt/src/velo.py index 6d93822b876..4fdd9ac9f8a 100644 --- a/pygmt/src/velo.py +++ b/pygmt/src/velo.py @@ -26,8 +26,6 @@ U="timestamp", V="verbose", W="pen", - X="xshift", - Y="yshift", Z="zvalue", c="panel", d="nodata", @@ -218,7 +216,6 @@ def velo(self, data=None, **kwargs): updated from the CPT (see ``cmap``). If instead modifier **+cf** is appended then the color from the cpt file is applied to symbol fill only [Default]. Use just **+c** to set both pen and fill color. - {xyshift} zvalue : str [**m**\|\ **e**\|\ **n**\|\ **u**\ ][**+e**]. Select the quantity that will be used with the CPT given via ``cmap`` diff --git a/pygmt/src/wiggle.py b/pygmt/src/wiggle.py index d0b74032750..226fbe7c62a 100644 --- a/pygmt/src/wiggle.py +++ b/pygmt/src/wiggle.py @@ -16,8 +16,6 @@ U="timestamp", V="verbose", W="pen", - X="xshift", - Y="yshift", Z="scale", b="binary", c="panel", @@ -82,7 +80,6 @@ def wiggle(self, data=None, x=None, y=None, z=None, **kwargs): {verbose} pen : str Specify outline pen attributes [Default is no outline]. - {xyshift} {binary} {panel} {nodata} diff --git a/pygmt/tests/test_config.py b/pygmt/tests/test_config.py index 234f28431bf..a1e591e8220 100644 --- a/pygmt/tests/test_config.py +++ b/pygmt/tests/test_config.py @@ -18,18 +18,18 @@ def test_config(): ) with config(FONT_LABEL="red", FONT_ANNOT_PRIMARY="red"): + fig.shift_origin(xshift="7c") fig.basemap( region=[0, 10, 0, 10], projection="X5c/5c", frame=["xaf+lred label", "yaf", "+tred annotation"], - xshift="7c", ) + fig.shift_origin(xshift="7c") fig.basemap( region=[0, 10, 0, 10], projection="X5c/5c", frame=["af", "+tBlue Annotation"], - xshift="7c", ) # Revert to default settings in current figure config(FONT_ANNOT_PRIMARY="black") @@ -131,7 +131,8 @@ def test_config_map_grid_cross_size(): frame=["pa1Hg", "sa45mg45m", "NWse"], verbose="e", ) - fig.basemap(frame=["pa1Hg", "sa45mg45m", "nwSE"], yshift=-3, verbose="e") + fig.shift_origin(yshift=-3) + fig.basemap(frame=["pa1Hg", "sa45mg45m", "nwSE"], verbose="e") return fig @@ -149,7 +150,8 @@ def test_config_map_grid_pen(): frame=["pa1Hg", "sa45mg45m", "NWse"], verbose="e", ) - fig.basemap(frame=["pa1Hg", "sa45mg45m", "nwSE"], yshift=-3, verbose="e") + fig.shift_origin(yshift=-3) + fig.basemap(frame=["pa1Hg", "sa45mg45m", "nwSE"], verbose="e") return fig @@ -167,7 +169,8 @@ def test_config_map_tick_length(): frame=["pa1Hg", "sa45mg45m", "NWse"], verbose="e", ) - fig.basemap(frame=["pa1Hg", "sa45mg45m", "nwSE"], yshift=-3, verbose="e") + fig.shift_origin(yshift=-3) + fig.basemap(frame=["pa1Hg", "sa45mg45m", "nwSE"], verbose="e") return fig @@ -185,5 +188,6 @@ def test_config_map_tick_pen(): frame=["pa1Hg", "sa45mg45m", "NWse"], verbose="e", ) - fig.basemap(frame=["pa1Hg", "sa45mg45m", "nwSE"], yshift=-3, verbose="e") + fig.shift_origin(yshift=-3) + fig.basemap(frame=["pa1Hg", "sa45mg45m", "nwSE"], verbose="e") return fig diff --git a/pygmt/tests/test_figure.py b/pygmt/tests/test_figure.py index 900c70d74ad..6f316780955 100644 --- a/pygmt/tests/test_figure.py +++ b/pygmt/tests/test_figure.py @@ -274,3 +274,24 @@ def test_figure_icc_gray(): with pytest.warns(expected_warning=FutureWarning) as record: fig.psconvert(icc_gray=True, prefix="Test") assert len(record) == 1 # check that only one warning was raised + + +def test_figure_deprecated_xshift_yshift(): + """ + Check if deprecation of parameters X/Y/xshift/yshift work correctly if + used. + """ + fig = Figure() + fig.basemap(region=[0, 1, 0, 1], projection="X1c/1c", frame=True) + with pytest.warns(expected_warning=SyntaxWarning) as record: + fig.plot(x=1, y=1, style="c3c", xshift="3c") + assert len(record) == 1 # check that only one warning was raised + with pytest.warns(expected_warning=SyntaxWarning) as record: + fig.plot(x=1, y=1, style="c3c", X="3c") + assert len(record) == 1 # check that only one warning was raised + with pytest.warns(expected_warning=SyntaxWarning) as record: + fig.plot(x=1, y=1, style="c3c", yshift="3c") + assert len(record) == 1 # check that only one warning was raised + with pytest.warns(expected_warning=SyntaxWarning) as record: + fig.plot(x=1, y=1, style="c3c", Y="3c") + assert len(record) == 1 # check that only one warning was raised