diff --git a/examples/tutorials/advanced/subplots.py b/examples/tutorials/advanced/subplots.py index 1fb43fc02a4..51b572d183b 100644 --- a/examples/tutorials/advanced/subplots.py +++ b/examples/tutorials/advanced/subplots.py @@ -100,7 +100,7 @@ nrows=2, ncols=2, figsize=("15c", "6c"), - autolabel=True, + auto_label=True, frame=["af", "WSne"], margins=["0.1c", "0.2c"], title="My Subplot Heading", @@ -117,7 +117,7 @@ # 15 cm wide and 6 cm high (``figsize=["15c", "6c"]``). In addition, we use # some optional parameters to fine-tune some details of the figure creation: # -# - ``autolabel=True``: Each subplot is automatically labelled 'abcd'. +# - ``auto_label=True``: Each subplot is automatically labeled 'abcd'. # - ``margins=["0.1c", "0.2c"]``: Adjusts the space between adjacent subplots. # In this case, it is set as 0.1 cm in the x-direction and 0.2 cm in the # y-direction. @@ -168,7 +168,7 @@ nrows=2, ncols=2, figsize=("15c", "6c"), # width of 15 cm, height of 6 cm - autolabel=True, + auto_label=True, margins=["0.3c", "0.2c"], # horizontal 0.3 cm and vertical 0.2 cm margins title="My Subplot Heading", sharex="b", # shared x-axis on the bottom side @@ -204,7 +204,7 @@ fig = pygmt.Figure() # Bottom row, two subplots -with fig.subplot(nrows=1, ncols=2, figsize=("15c", "3c"), autolabel="b)"): +with fig.subplot(nrows=1, ncols=2, figsize=("15c", "3c"), auto_label="b)"): fig.basemap( region=[0, 5, 0, 5], projection="X?", frame=["af", "WSne"], panel=[0, 0] ) @@ -214,7 +214,7 @@ # Move plot origin by 1 cm above the height of the entire figure fig.shift_origin(yshift="h+1c") # Top row, one subplot -with fig.subplot(nrows=1, ncols=1, figsize=("15c", "3c"), autolabel="a)"): +with fig.subplot(nrows=1, ncols=1, figsize=("15c", "3c"), auto_label="a)"): fig.basemap( region=[0, 10, 0, 10], projection="X?", frame=["af", "WSne"], panel=[0, 0] ) @@ -223,19 +223,19 @@ fig.show() # %% -# We start by drawing the bottom two subplots, setting ``autolabel="b)"`` so -# that the subplots are labelled 'b)' and 'c)'. Next, we use +# We start by drawing the bottom two subplots, setting ``auto_label="b)"`` so +# that the subplots are labeled 'b)' and 'c)'. Next, we use # :meth:`pygmt.Figure.shift_origin` to move the plot origin 1 cm above the # **h**\ eight of the entire figure that is currently plotted (i.e. the bottom # row subplots). A single subplot is then plotted on the top row. You may need # to adjust the ``yshift`` parameter to make your plot look nice. This top row -# uses ``autolabel="a)"``, and we also plotted some text inside. Note that +# uses ``auto_label="a)"``, and we also plotted some text inside. Note that # ``projection="X?"`` was used to let GMT automatically determine the size of # the subplot according to the size of the subplot area. # %% -# You can also manually override the ``autolabel`` for each subplot using for -# example, ``fig.set_panel(..., fixedlabel="b) Panel 2")`` which would allow +# You can also manually override the ``auto_label`` for each subplot using for +# example, ``fig.set_panel(..., fixed_label="b) Panel 2")`` which would allow # you to manually label a single subplot as you wish. This can be useful for # adding a more descriptive subtitle to individual subplots. diff --git a/pygmt/src/subplot.py b/pygmt/src/subplot.py index 4df32ed38fb..5444aca02f4 100644 --- a/pygmt/src/subplot.py +++ b/pygmt/src/subplot.py @@ -11,6 +11,7 @@ from pygmt.exceptions import GMTInvalidInput, GMTValueError from pygmt.helpers import ( build_arg_list, + deprecate_parameter, fmt_docstring, kwargs_to_strings, use_alias, @@ -18,11 +19,12 @@ @fmt_docstring +@deprecate_parameter("autolabel", "auto_label", "v0.18.0", remove_version="v0.20.0") @contextlib.contextmanager @use_alias( Ff="figsize", Fs="subsize", - A="autolabel", + A="auto_label", C="clearance", SC="sharex", SR="sharey", @@ -72,7 +74,7 @@ def subplot( Note that only one of ``figsize`` or ``subsize`` can be provided at once. - autolabel : bool or str + auto_label : bool or str [*autolabel*][**+c**\ *dx*\ [/*dy*]][**+g**\ *fill*][**+j**\|\ **J**\ *refpoint*][**+o**\ *dx*\ [/*dy*]][**+p**\ *pen*][**+r**\|\ **R**]\ [**+v**]. Specify automatic tagging of each subplot. Append either a number or letter @@ -203,8 +205,9 @@ def subplot( @fmt_docstring +@deprecate_parameter("fixedlabel", "fixed_label", "v0.18.0", remove_version="v0.20.0") @contextlib.contextmanager -@use_alias(A="fixedlabel", C="clearance") +@use_alias(A="fixed_label", C="clearance") def set_panel( self, panel: int | Sequence[int] | None = None, @@ -232,17 +235,17 @@ def set_panel( *index* or (*row*, *col*). Sets the current subplot until further notice. **Note**: First *row* or *col* is 0, not 1. If not given we go to the next subplot by order specified via - ``autolabel`` in :meth:`pygmt.Figure.subplot`. As an alternative, you may bypass - using :meth:`pygmt.Figure.set_panel` and instead supply the common option + ``auto_label`` in :meth:`pygmt.Figure.subplot`. As an alternative, you may + bypass using :meth:`pygmt.Figure.set_panel` and instead supply the common option **panel**=(*row*, *col*) to the first plot command you issue in that subplot. GMT maintains information about the current figure and subplot. Also, you may give the one-dimensional *index* instead which starts at 0 and follows the row - or column order set via ``autolabel`` in :meth:`pygmt.Figure.subplot`. + or column order set via ``auto_label`` in :meth:`pygmt.Figure.subplot`. - fixedlabel : str + fixed_label : str Overrides the automatic labeling with the given string. No modifiers are allowed. Placement, justification, etc. are all inherited from how - ``autolabel`` was specified by the initial :meth:`pygmt.Figure.subplot` + ``auto_label`` was specified by the initial :meth:`pygmt.Figure.subplot` command. clearance : str or list diff --git a/pygmt/tests/test_subplot.py b/pygmt/tests/test_subplot.py index 62b015f188e..897a3385ffa 100644 --- a/pygmt/tests/test_subplot.py +++ b/pygmt/tests/test_subplot.py @@ -40,7 +40,7 @@ def test_subplot_direct(): @pytest.mark.mpl_image_compare def test_subplot_autolabel_margins_title(): """ - Make subplot figure with autolabels, setting some margins and a title. + Make subplot figure with automatic labels, setting some margins and a title. """ fig = Figure() @@ -48,7 +48,7 @@ def test_subplot_autolabel_margins_title(): nrows=2, ncols=1, figsize=("15c", "6c"), - autolabel=True, + auto_label=True, margins=["0.3c", "0.1c"], title="Subplot Title", ):