From a3fa2149f88290a999a9d4e31e5750997b67ee13 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 16 Mar 2024 19:46:09 +0100 Subject: [PATCH 01/39] Use list instead of tuple --- pygmt/src/grdcontour.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pygmt/src/grdcontour.py b/pygmt/src/grdcontour.py index 89268d8fe51..5c8e73f89d2 100644 --- a/pygmt/src/grdcontour.py +++ b/pygmt/src/grdcontour.py @@ -58,11 +58,11 @@ def grdcontour(self, grid, **kwargs): contours specified in ``interval``. - Specify a fixed annotation interval *annot_int* or a - single annotation level +\ *annot_int*. + single annotation level **+**\ *annot_int*. - Disable all annotation with **-**. - Optional label modifiers can be specified as a single string - ``"[annot_int]+e"`` or with a list of arguments - ``([annot_int], "e", "f10p", "gred")``. + ``"annot_int+e+f10p+gred"`` or with a list of arguments + ``[annot_int, "e", "f10p", "gred"]``. limit : str or list of 2 ints *low*/*high*. Do no draw contours below `low` or above `high`, specify as string From 05b5abbf88190e03ab591187b223cae69872dc26 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Tue, 19 Mar 2024 12:02:17 +0100 Subject: [PATCH 02/39] Remove list input option for annotation parameter --- pygmt/src/grdcontour.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pygmt/src/grdcontour.py b/pygmt/src/grdcontour.py index 5c8e73f89d2..2e54d7346e8 100644 --- a/pygmt/src/grdcontour.py +++ b/pygmt/src/grdcontour.py @@ -28,7 +28,7 @@ t="transparency", ) @kwargs_to_strings( - R="sequence", L="sequence", A="sequence_plus", c="sequence_comma", p="sequence" + R="sequence", L="sequence", c="sequence_comma", p="sequence" ) def grdcontour(self, grid, **kwargs): r""" @@ -53,16 +53,17 @@ def grdcontour(self, grid, **kwargs): angle (col 3). - A fixed contour interval *cont_int* or a single contour with +\ *cont_int*. - annotation : str, int, or list + annotation : int or str Specify or disable annotated contour levels, modifies annotated contours specified in ``interval``. - Specify a fixed annotation interval *annot_int* or a single annotation level **+**\ *annot_int*. - Disable all annotation with **-**. - - Optional label modifiers can be specified as a single string - ``"annot_int+e+f10p+gred"`` or with a list of arguments - ``[annot_int, "e", "f10p", "gred"]``. + - The appearence can be adjusted by appending different modifiers, e.g., + ``"annot_int+f10p+gred"`` gives annotations with a font size of 10 + points and a red filled box. For all available modifiers see + :gmt-docs:`grdcontour.html#a`. limit : str or list of 2 ints *low*/*high*. Do no draw contours below `low` or above `high`, specify as string From 731d0148e2eb9bb9dd3fd34856f8999bc02fddf1 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Tue, 19 Mar 2024 12:07:14 +0100 Subject: [PATCH 03/39] Fix line length --- pygmt/src/grdcontour.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pygmt/src/grdcontour.py b/pygmt/src/grdcontour.py index 2e54d7346e8..d4a03a862c8 100644 --- a/pygmt/src/grdcontour.py +++ b/pygmt/src/grdcontour.py @@ -27,9 +27,7 @@ p="perspective", t="transparency", ) -@kwargs_to_strings( - R="sequence", L="sequence", c="sequence_comma", p="sequence" -) +@kwargs_to_strings(R="sequence", L="sequence", c="sequence_comma", p="sequence") def grdcontour(self, grid, **kwargs): r""" Convert grids or images to contours and plot them on maps. From c8b805b3df43e7eeb867c3155fe28aac6e210410 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Tue, 19 Mar 2024 12:44:24 +0100 Subject: [PATCH 04/39] Update syntax to GMT 6.5 --- pygmt/src/grdcontour.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/grdcontour.py b/pygmt/src/grdcontour.py index d4a03a862c8..de9915748ab 100644 --- a/pygmt/src/grdcontour.py +++ b/pygmt/src/grdcontour.py @@ -57,7 +57,7 @@ def grdcontour(self, grid, **kwargs): - Specify a fixed annotation interval *annot_int* or a single annotation level **+**\ *annot_int*. - - Disable all annotation with **-**. + - Disable all annotations by appending **n**. - The appearence can be adjusted by appending different modifiers, e.g., ``"annot_int+f10p+gred"`` gives annotations with a font size of 10 points and a red filled box. For all available modifiers see From 584956ee68ef806505b0d7ae507ba00b6a6f9fb1 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Tue, 19 Mar 2024 12:46:12 +0100 Subject: [PATCH 05/39] Update allowed input data type --- pygmt/src/grdcontour.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/grdcontour.py b/pygmt/src/grdcontour.py index de9915748ab..2cf2855462f 100644 --- a/pygmt/src/grdcontour.py +++ b/pygmt/src/grdcontour.py @@ -51,7 +51,7 @@ def grdcontour(self, grid, **kwargs): angle (col 3). - A fixed contour interval *cont_int* or a single contour with +\ *cont_int*. - annotation : int or str + annotation : float or str Specify or disable annotated contour levels, modifies annotated contours specified in ``interval``. From 13360d4c34c8305ed80b55adb71db334e10c19f2 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Wed, 20 Mar 2024 09:16:36 +0100 Subject: [PATCH 06/39] Fix typo --- pygmt/src/grdcontour.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/grdcontour.py b/pygmt/src/grdcontour.py index 2cf2855462f..c49549d19ca 100644 --- a/pygmt/src/grdcontour.py +++ b/pygmt/src/grdcontour.py @@ -58,7 +58,7 @@ def grdcontour(self, grid, **kwargs): - Specify a fixed annotation interval *annot_int* or a single annotation level **+**\ *annot_int*. - Disable all annotations by appending **n**. - - The appearence can be adjusted by appending different modifiers, e.g., + - The appearance can be adjusted by appending different modifiers, e.g., ``"annot_int+f10p+gred"`` gives annotations with a font size of 10 points and a red filled box. For all available modifiers see :gmt-docs:`grdcontour.html#a`. From 57837fb7e4361d4962f77e113568121546af5326 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 21 Mar 2024 14:53:41 +0100 Subject: [PATCH 07/39] Update docstring --- pygmt/src/grdcontour.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pygmt/src/grdcontour.py b/pygmt/src/grdcontour.py index c49549d19ca..e22cc153a10 100644 --- a/pygmt/src/grdcontour.py +++ b/pygmt/src/grdcontour.py @@ -55,12 +55,14 @@ def grdcontour(self, grid, **kwargs): Specify or disable annotated contour levels, modifies annotated contours specified in ``interval``. - - Specify a fixed annotation interval *annot_int* or a - single annotation level **+**\ *annot_int*. + - Specify a fixed annotation interval by ``*annot_int*`` or ``"annot_int"``. + - Specify a single annotation level by ``[*annot_int*]`` or + ``"*annot_int*\ **,**"``. + - Specify specific annotation levels by a list or a comma separated string - Disable all annotations by appending **n**. - The appearance can be adjusted by appending different modifiers, e.g., - ``"annot_int+f10p+gred"`` gives annotations with a font size of 10 - points and a red filled box. For all available modifiers see + ``"annot_int+f10p+gred"`` gives annotations with a font size of 10 points + and a red filled box. For all available modifiers see :gmt-docs:`grdcontour.html#a`. limit : str or list of 2 ints *low*/*high*. From 4f06fe4768355f5aed88e6076f6d721446b991a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Thu, 21 Mar 2024 14:56:00 +0100 Subject: [PATCH 08/39] Use sequence instead of sequence_comma Co-authored-by: Dongdong Tian --- pygmt/src/grdcontour.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/grdcontour.py b/pygmt/src/grdcontour.py index e22cc153a10..77516459643 100644 --- a/pygmt/src/grdcontour.py +++ b/pygmt/src/grdcontour.py @@ -27,7 +27,7 @@ p="perspective", t="transparency", ) -@kwargs_to_strings(R="sequence", L="sequence", c="sequence_comma", p="sequence") +@kwargs_to_strings(R="sequence", L="sequence", A="squence", c="sequence_comma", p="sequence") def grdcontour(self, grid, **kwargs): r""" Convert grids or images to contours and plot them on maps. From 311015e981cbefdb9ec7b7d2440c763cd62ef96f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Thu, 21 Mar 2024 14:56:21 +0100 Subject: [PATCH 09/39] Extend allow input formats Co-authored-by: Dongdong Tian --- pygmt/src/grdcontour.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/grdcontour.py b/pygmt/src/grdcontour.py index 77516459643..83c9f1313c3 100644 --- a/pygmt/src/grdcontour.py +++ b/pygmt/src/grdcontour.py @@ -51,7 +51,7 @@ def grdcontour(self, grid, **kwargs): angle (col 3). - A fixed contour interval *cont_int* or a single contour with +\ *cont_int*. - annotation : float or str + annotation : float or str or list Specify or disable annotated contour levels, modifies annotated contours specified in ``interval``. From 4ae50738d900a2c1d588fd289b9be37dee9019f5 Mon Sep 17 00:00:00 2001 From: actions-bot <58130806+actions-bot@users.noreply.github.com> Date: Thu, 21 Mar 2024 13:58:52 +0000 Subject: [PATCH 10/39] [format-command] fixes --- pygmt/src/grdcontour.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pygmt/src/grdcontour.py b/pygmt/src/grdcontour.py index 83c9f1313c3..d8c9f4f8467 100644 --- a/pygmt/src/grdcontour.py +++ b/pygmt/src/grdcontour.py @@ -27,7 +27,9 @@ p="perspective", t="transparency", ) -@kwargs_to_strings(R="sequence", L="sequence", A="squence", c="sequence_comma", p="sequence") +@kwargs_to_strings( + R="sequence", L="sequence", A="squence", c="sequence_comma", p="sequence" +) def grdcontour(self, grid, **kwargs): r""" Convert grids or images to contours and plot them on maps. From 6925eca80b213ace930b5e8ed080aefa1ed68541 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 21 Mar 2024 21:17:19 +0100 Subject: [PATCH 11/39] Fix typo --- pygmt/src/grdcontour.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/grdcontour.py b/pygmt/src/grdcontour.py index d8c9f4f8467..ccd9550e58a 100644 --- a/pygmt/src/grdcontour.py +++ b/pygmt/src/grdcontour.py @@ -28,7 +28,7 @@ t="transparency", ) @kwargs_to_strings( - R="sequence", L="sequence", A="squence", c="sequence_comma", p="sequence" + R="sequence", L="sequence", A="sequence", c="sequence_comma", p="sequence" ) def grdcontour(self, grid, **kwargs): r""" From bbeb83cfe75c8738c2bc51f09bb97e8dad2bb1a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Sat, 23 Mar 2024 21:48:24 +0100 Subject: [PATCH 12/39] Shorten documentation Co-authored-by: Dongdong Tian --- pygmt/src/grdcontour.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/grdcontour.py b/pygmt/src/grdcontour.py index ccd9550e58a..5f26596a3ce 100644 --- a/pygmt/src/grdcontour.py +++ b/pygmt/src/grdcontour.py @@ -57,7 +57,7 @@ def grdcontour(self, grid, **kwargs): Specify or disable annotated contour levels, modifies annotated contours specified in ``interval``. - - Specify a fixed annotation interval by ``*annot_int*`` or ``"annot_int"``. + - Specify a fixed annotation interval - Specify a single annotation level by ``[*annot_int*]`` or ``"*annot_int*\ **,**"``. - Specify specific annotation levels by a list or a comma separated string From 078553c3ad7f178be257b355de081256e132602b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Sat, 23 Mar 2024 21:48:53 +0100 Subject: [PATCH 13/39] Shorten documentation Co-authored-by: Dongdong Tian --- pygmt/src/grdcontour.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pygmt/src/grdcontour.py b/pygmt/src/grdcontour.py index 5f26596a3ce..65156d87122 100644 --- a/pygmt/src/grdcontour.py +++ b/pygmt/src/grdcontour.py @@ -58,9 +58,7 @@ def grdcontour(self, grid, **kwargs): contours specified in ``interval``. - Specify a fixed annotation interval - - Specify a single annotation level by ``[*annot_int*]`` or - ``"*annot_int*\ **,**"``. - - Specify specific annotation levels by a list or a comma separated string + - Specify a list of annotation levels - Disable all annotations by appending **n**. - The appearance can be adjusted by appending different modifiers, e.g., ``"annot_int+f10p+gred"`` gives annotations with a font size of 10 points From 1e114cfc7cc63b464aa6720a4d4e7ce4f53965e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Sat, 23 Mar 2024 21:49:29 +0100 Subject: [PATCH 14/39] Clearify documentation Co-authored-by: Dongdong Tian --- pygmt/src/grdcontour.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/grdcontour.py b/pygmt/src/grdcontour.py index 65156d87122..209812338f7 100644 --- a/pygmt/src/grdcontour.py +++ b/pygmt/src/grdcontour.py @@ -59,7 +59,7 @@ def grdcontour(self, grid, **kwargs): - Specify a fixed annotation interval - Specify a list of annotation levels - - Disable all annotations by appending **n**. + - Disable all annotations by setting ``annotation="n"``. - The appearance can be adjusted by appending different modifiers, e.g., ``"annot_int+f10p+gred"`` gives annotations with a font size of 10 points and a red filled box. For all available modifiers see From 0cd2f0b40dac271753ee15eb6800328a972f1c2d Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 25 Mar 2024 14:12:07 +0100 Subject: [PATCH 15/39] Update docs, Add code for list input --- pygmt/src/grdcontour.py | 60 ++++++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 21 deletions(-) diff --git a/pygmt/src/grdcontour.py b/pygmt/src/grdcontour.py index 209812338f7..e96e7818dd6 100644 --- a/pygmt/src/grdcontour.py +++ b/pygmt/src/grdcontour.py @@ -3,7 +3,13 @@ """ from pygmt.clib import Session -from pygmt.helpers import build_arg_string, fmt_docstring, kwargs_to_strings, use_alias +from pygmt.helpers import ( + build_arg_string, + fmt_docstring, + is_nonstr_iter, + kwargs_to_strings, + use_alias, +) __doctest_skip__ = ["grdcontour"] @@ -43,24 +49,23 @@ def grdcontour(self, grid, **kwargs): Parameters ---------- {grid} - interval : str or int + interval : float, list, or str Specify the contour lines to generate. - - The file name of a CPT file where the color boundaries will - be used as contour levels. - - The file name of a 2 (or 3) column file containing the contour - levels (col 1), (**C**)ontour or (**A**)nnotate (col 2), and optional - angle (col 3). - - A fixed contour interval *cont_int* or a single contour with - +\ *cont_int*. - annotation : float or str or list + - The file name of a CPT file where the color boundaries will be used as + contour levels + - The file name of a 2 (or 3) column file containing the contour levels (col 0), + (**C**)ontour or (**A**)nnotate (col 1), and optional angle (col 2) + - A fixed contour interval + - A list of contour levels + annotation : float, list, or str Specify or disable annotated contour levels, modifies annotated contours specified in ``interval``. - Specify a fixed annotation interval - Specify a list of annotation levels - Disable all annotations by setting ``annotation="n"``. - - The appearance can be adjusted by appending different modifiers, e.g., + - Adjust the appearance by appending different modifiers, e.g., ``"annot_int+f10p+gred"`` gives annotations with a font size of 10 points and a red filled box. For all available modifiers see :gmt-docs:`grdcontour.html#a`. @@ -97,32 +102,45 @@ def grdcontour(self, grid, **kwargs): Example ------- >>> import pygmt - >>> # load the 15 arc-minutes grid with "gridline" registration - >>> # in a specified region + >>> # Load the 15 arc-minutes grid with "gridline" registration in the + >>> # specified region >>> grid = pygmt.datasets.load_earth_relief( ... resolution="15m", ... region=[-92.5, -82.5, -3, 7], ... registration="gridline", ... ) - >>> # create a new plot with pygmt.Figure() + >>> # Create a new plot with pygmt.Figure() >>> fig = pygmt.Figure() - >>> # create the contour plot + >>> # Create the contour plot >>> fig.grdcontour( - ... # pass in the grid downloaded above + ... # Pass in the grid downloaded above ... grid=grid, - ... # set the interval for contour lines at 250 meters + ... # Set the interval for contour lines at 250 meters ... interval=250, - ... # set the interval for annotated contour lines at 1,000 meters + ... # Set the interval for annotated contour lines at 1,000 meters ... annotation=1000, - ... # add a frame for the plot + ... # Add a frame for the plot ... frame="a", - ... # set the projection to Mercator for the 10 cm figure + ... # Set the projection to Mercator for the 10 cm figure ... projection="M10c", ... ) - >>> # show the plot + >>> # Show the plot >>> fig.show() """ kwargs = self._preprocess(**kwargs) + + if is_nonstr_iter(kwargs.get("A")): + if len(kwargs["A"]) == 1: + kwargs["A"] = str(kwargs["A"]) + "," + else: + kwargs["A"] = ",".join(f"{item}" for item in kwargs["A"]) + + if is_nonstr_iter(kwargs.get("C")): + if len(kwargs["C"]) == 1: + kwargs["C"] = str(kwargs["C"]) + "," + else: + kwargs["C"] = ",".join(f"{item}" for item in kwargs["C"]) + with Session() as lib: with lib.virtualfile_in(check_kind="raster", data=grid) as vingrd: lib.call_module( From 581eef456a344cc593de01b738b92e03708a9fa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Tue, 26 Mar 2024 13:10:56 +0100 Subject: [PATCH 16/39] Process argument passt to "A" manually Co-authored-by: Dongdong Tian --- pygmt/src/grdcontour.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/grdcontour.py b/pygmt/src/grdcontour.py index e96e7818dd6..844b20975c8 100644 --- a/pygmt/src/grdcontour.py +++ b/pygmt/src/grdcontour.py @@ -34,7 +34,7 @@ t="transparency", ) @kwargs_to_strings( - R="sequence", L="sequence", A="sequence", c="sequence_comma", p="sequence" + R="sequence", L="sequence", c="sequence_comma", p="sequence" ) def grdcontour(self, grid, **kwargs): r""" From a86305c60bc9dac9b17b16a0bbdc413357d4adef Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Tue, 26 Mar 2024 13:13:28 +0100 Subject: [PATCH 17/39] Fix line length --- pygmt/src/grdcontour.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pygmt/src/grdcontour.py b/pygmt/src/grdcontour.py index 844b20975c8..97c9374b6a6 100644 --- a/pygmt/src/grdcontour.py +++ b/pygmt/src/grdcontour.py @@ -33,9 +33,7 @@ p="perspective", t="transparency", ) -@kwargs_to_strings( - R="sequence", L="sequence", c="sequence_comma", p="sequence" -) +@kwargs_to_strings(R="sequence", L="sequence", c="sequence_comma", p="sequence") def grdcontour(self, grid, **kwargs): r""" Convert grids or images to contours and plot them on maps. From 11b2dacbf72996766cff29386bf0f9a6145b9f70 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Wed, 24 Apr 2024 23:47:50 +0200 Subject: [PATCH 18/39] Add tests --- pygmt/tests/test_grdcontour.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/pygmt/tests/test_grdcontour.py b/pygmt/tests/test_grdcontour.py index 2cedd80dc14..32a0da8ff6b 100644 --- a/pygmt/tests/test_grdcontour.py +++ b/pygmt/tests/test_grdcontour.py @@ -33,6 +33,32 @@ def test_grdcontour(grid): return fig +def test_grdcontour_one_contour(grid): + """ + Plot a contour image using an xarray grid with one fixed contour. + """ + fig = Figure() + fig.grdcontour( + grid=grid, interval=[50], annotation=[200], projection="M10c", frame=True + ) + return fig + + +def test_grdcontour_specific_contours(grid): + """ + Plot a contour image using an xarray grid with specific fixed contours. + """ + fig = Figure() + fig.grdcontour( + grid=grid, + interval=[200, 300, 350, 400], + annotation=[300, 400], + projection="M10c", + frame=True, + ) + return fig + + @pytest.mark.benchmark @pytest.mark.mpl_image_compare def test_grdcontour_labels(grid): From 4708483e5b8120266ab14890e3259520235775d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Thu, 25 Apr 2024 10:37:24 +0200 Subject: [PATCH 19/39] Update pygmt/src/grdcontour.py Co-authored-by: Dongdong Tian --- pygmt/src/grdcontour.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/grdcontour.py b/pygmt/src/grdcontour.py index c8482f6d9b5..a7de3f0f93a 100644 --- a/pygmt/src/grdcontour.py +++ b/pygmt/src/grdcontour.py @@ -135,7 +135,7 @@ def grdcontour(self, grid, **kwargs): if is_nonstr_iter(kwargs.get("C")): if len(kwargs["C"]) == 1: - kwargs["C"] = str(kwargs["C"]) + "," + kwargs["C"] = str(kwargs["C"][0]) + "," else: kwargs["C"] = ",".join(f"{item}" for item in kwargs["C"]) From 56afbe83895bf964c5517205b5ca8f5e153acbce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Thu, 25 Apr 2024 10:37:41 +0200 Subject: [PATCH 20/39] Update pygmt/src/grdcontour.py Co-authored-by: Dongdong Tian --- pygmt/src/grdcontour.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/grdcontour.py b/pygmt/src/grdcontour.py index a7de3f0f93a..bcecc6c0a4f 100644 --- a/pygmt/src/grdcontour.py +++ b/pygmt/src/grdcontour.py @@ -129,7 +129,7 @@ def grdcontour(self, grid, **kwargs): if is_nonstr_iter(kwargs.get("A")): if len(kwargs["A"]) == 1: - kwargs["A"] = str(kwargs["A"]) + "," + kwargs["A"] = str(kwargs["A"][0]) + "," else: kwargs["A"] = ",".join(f"{item}" for item in kwargs["A"]) From c8772bff9998b865046efb5ba416b1b1abec7962 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 25 Apr 2024 11:08:23 +0200 Subject: [PATCH 21/39] Use for loop for A and C --- pygmt/src/grdcontour.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/pygmt/src/grdcontour.py b/pygmt/src/grdcontour.py index bcecc6c0a4f..0644dd94d64 100644 --- a/pygmt/src/grdcontour.py +++ b/pygmt/src/grdcontour.py @@ -127,17 +127,12 @@ def grdcontour(self, grid, **kwargs): """ kwargs = self._preprocess(**kwargs) - if is_nonstr_iter(kwargs.get("A")): - if len(kwargs["A"]) == 1: - kwargs["A"] = str(kwargs["A"][0]) + "," - else: - kwargs["A"] = ",".join(f"{item}" for item in kwargs["A"]) - - if is_nonstr_iter(kwargs.get("C")): - if len(kwargs["C"]) == 1: - kwargs["C"] = str(kwargs["C"][0]) + "," - else: - kwargs["C"] = ",".join(f"{item}" for item in kwargs["C"]) + for arg in ["A", "C"]: + if is_nonstr_iter(kwargs.get(arg)): + if len(kwargs[ar]) == 1: + kwargs[arg] = str(kwargs[arg][0]) + "," + else: + kwargs[arg] = ",".join(f"{item}" for item in kwargs[arg]) with Session() as lib: with lib.virtualfile_in(check_kind="raster", data=grid) as vingrd: From 9a9ae495aaacdc8d69db7944eea39177cb127bb7 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 25 Apr 2024 11:14:08 +0200 Subject: [PATCH 22/39] Fix typo --- pygmt/src/grdcontour.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/grdcontour.py b/pygmt/src/grdcontour.py index 0644dd94d64..53a1d346d66 100644 --- a/pygmt/src/grdcontour.py +++ b/pygmt/src/grdcontour.py @@ -129,7 +129,7 @@ def grdcontour(self, grid, **kwargs): for arg in ["A", "C"]: if is_nonstr_iter(kwargs.get(arg)): - if len(kwargs[ar]) == 1: + if len(kwargs[arg]) == 1: kwargs[arg] = str(kwargs[arg][0]) + "," else: kwargs[arg] = ",".join(f"{item}" for item in kwargs[arg]) From 32c4f90a68b564a03af04e48fbb00abd870d3a1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Thu, 25 Apr 2024 13:23:49 +0200 Subject: [PATCH 23/39] Update pygmt/tests/test_grdcontour.py Co-authored-by: Dongdong Tian --- pygmt/tests/test_grdcontour.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pygmt/tests/test_grdcontour.py b/pygmt/tests/test_grdcontour.py index 32a0da8ff6b..bf2068326b8 100644 --- a/pygmt/tests/test_grdcontour.py +++ b/pygmt/tests/test_grdcontour.py @@ -33,6 +33,7 @@ def test_grdcontour(grid): return fig +@pytest.mark.mpl_image_compare def test_grdcontour_one_contour(grid): """ Plot a contour image using an xarray grid with one fixed contour. From d9c734b984c2eff06b5480b4f49f4a0eb7030907 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Thu, 25 Apr 2024 13:24:06 +0200 Subject: [PATCH 24/39] Update pygmt/tests/test_grdcontour.py Co-authored-by: Dongdong Tian --- pygmt/tests/test_grdcontour.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/tests/test_grdcontour.py b/pygmt/tests/test_grdcontour.py index bf2068326b8..29b8bdc039e 100644 --- a/pygmt/tests/test_grdcontour.py +++ b/pygmt/tests/test_grdcontour.py @@ -44,7 +44,7 @@ def test_grdcontour_one_contour(grid): ) return fig - +@pytest.mark.mpl_image_compare def test_grdcontour_specific_contours(grid): """ Plot a contour image using an xarray grid with specific fixed contours. From 9f394f7fba951759712a9997d46ab070c83af38e Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 25 Apr 2024 13:48:16 +0200 Subject: [PATCH 25/39] Explain code block for 'A' and 'C' --- pygmt/src/grdcontour.py | 8 ++++++-- pygmt/tests/test_grdcontour.py | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pygmt/src/grdcontour.py b/pygmt/src/grdcontour.py index 53a1d346d66..892ff4ec19a 100644 --- a/pygmt/src/grdcontour.py +++ b/pygmt/src/grdcontour.py @@ -127,11 +127,15 @@ def grdcontour(self, grid, **kwargs): """ kwargs = self._preprocess(**kwargs) + # Specify levels for contours or annotations + # One level is converted to a string with a trailing comma to separate it from + # specifying an interval + # Multiple levels are concatenated to a comma-separated string for arg in ["A", "C"]: if is_nonstr_iter(kwargs.get(arg)): - if len(kwargs[arg]) == 1: + if len(kwargs[arg]) == 1: # One level kwargs[arg] = str(kwargs[arg][0]) + "," - else: + else: # Multiple levels kwargs[arg] = ",".join(f"{item}" for item in kwargs[arg]) with Session() as lib: diff --git a/pygmt/tests/test_grdcontour.py b/pygmt/tests/test_grdcontour.py index 29b8bdc039e..9dc45ce5692 100644 --- a/pygmt/tests/test_grdcontour.py +++ b/pygmt/tests/test_grdcontour.py @@ -44,6 +44,7 @@ def test_grdcontour_one_contour(grid): ) return fig + @pytest.mark.mpl_image_compare def test_grdcontour_specific_contours(grid): """ From 557af15f8413bf325a6a4d8be0a65db8b21045a0 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 25 Apr 2024 22:31:47 +0200 Subject: [PATCH 26/39] Update tests --- pygmt/tests/test_grdcontour.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/pygmt/tests/test_grdcontour.py b/pygmt/tests/test_grdcontour.py index 9dc45ce5692..cfcfdbe2752 100644 --- a/pygmt/tests/test_grdcontour.py +++ b/pygmt/tests/test_grdcontour.py @@ -24,7 +24,8 @@ def fixture_grid(): @pytest.mark.mpl_image_compare def test_grdcontour(grid): """ - Plot a contour image using an xarray grid with fixed contour interval. + Plot a contour image using an xarray grid with fixed (different) contour and + annotation intervals. """ fig = Figure() fig.grdcontour( @@ -34,27 +35,29 @@ def test_grdcontour(grid): @pytest.mark.mpl_image_compare -def test_grdcontour_one_contour(grid): +def test_grdcontour_one_level(grid): """ - Plot a contour image using an xarray grid with one fixed contour. + Plot a contour image using an xarray grid with one contour level and one + (different) annotation level. """ fig = Figure() fig.grdcontour( - grid=grid, interval=[50], annotation=[200], projection="M10c", frame=True + grid=grid, interval=[400], annotation=[570], projection="M10c", frame=True ) return fig @pytest.mark.mpl_image_compare -def test_grdcontour_specific_contours(grid): +def test_grdcontour_multiple_levels(grid): """ - Plot a contour image using an xarray grid with specific fixed contours. + Plot a contour image using an xarray grid with multiple (different) contour + and annotation levels. """ fig = Figure() fig.grdcontour( grid=grid, - interval=[200, 300, 350, 400], - annotation=[300, 400], + interval=[400, 450, 500], + annotation=[400, 570], projection="M10c", frame=True, ) From e964dda005deb79df3ba2ae22c96928625ddd64d Mon Sep 17 00:00:00 2001 From: Yvonne Date: Thu, 25 Apr 2024 20:42:38 +0000 Subject: [PATCH 27/39] Add test_grdcontour_one_level.png into DVC --- pygmt/tests/baseline/test_grdcontour_one_level.png.dvc | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100755 pygmt/tests/baseline/test_grdcontour_one_level.png.dvc diff --git a/pygmt/tests/baseline/test_grdcontour_one_level.png.dvc b/pygmt/tests/baseline/test_grdcontour_one_level.png.dvc new file mode 100755 index 00000000000..4072632ab00 --- /dev/null +++ b/pygmt/tests/baseline/test_grdcontour_one_level.png.dvc @@ -0,0 +1,6 @@ +outs: +- md5: fc624766f0b8eac8206735a05c7c9662 + size: 45023 + isexec: true + hash: md5 + path: test_grdcontour_one_level.png From 4501babc95e838ed134daa93bdb44d4d19080ecf Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 25 Apr 2024 23:20:10 +0200 Subject: [PATCH 28/39] Add test_grdcontour_multiple_levels.png into DVC --- .../tests/baseline/test_grdcontour_multiple_levels.png.dvc | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100755 pygmt/tests/baseline/test_grdcontour_multiple_levels.png.dvc diff --git a/pygmt/tests/baseline/test_grdcontour_multiple_levels.png.dvc b/pygmt/tests/baseline/test_grdcontour_multiple_levels.png.dvc new file mode 100755 index 00000000000..e0558fff47d --- /dev/null +++ b/pygmt/tests/baseline/test_grdcontour_multiple_levels.png.dvc @@ -0,0 +1,6 @@ +outs: +- md5: 4d20cdb71af2e6568f64f0246ec860ea + size: 64008 + isexec: true + hash: md5 + path: test_grdcontour_multiple_levels.png From 5fa02fbea37266a0ffa499f1f26326afc13a74e8 Mon Sep 17 00:00:00 2001 From: actions-bot <58130806+actions-bot@users.noreply.github.com> Date: Thu, 25 Apr 2024 21:24:16 +0000 Subject: [PATCH 29/39] [format-command] fixes --- pygmt/tests/baseline/test_grdcontour_multiple_levels.png.dvc | 0 pygmt/tests/baseline/test_grdcontour_one_level.png.dvc | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 pygmt/tests/baseline/test_grdcontour_multiple_levels.png.dvc mode change 100755 => 100644 pygmt/tests/baseline/test_grdcontour_one_level.png.dvc diff --git a/pygmt/tests/baseline/test_grdcontour_multiple_levels.png.dvc b/pygmt/tests/baseline/test_grdcontour_multiple_levels.png.dvc old mode 100755 new mode 100644 diff --git a/pygmt/tests/baseline/test_grdcontour_one_level.png.dvc b/pygmt/tests/baseline/test_grdcontour_one_level.png.dvc old mode 100755 new mode 100644 From 988d77e6eebbd8cf707d643cf176d6f074caf040 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Fri, 26 Apr 2024 09:04:51 +0200 Subject: [PATCH 30/39] Add period Co-authored-by: Dongdong Tian --- pygmt/src/grdcontour.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pygmt/src/grdcontour.py b/pygmt/src/grdcontour.py index 892ff4ec19a..0f4538f46cb 100644 --- a/pygmt/src/grdcontour.py +++ b/pygmt/src/grdcontour.py @@ -127,10 +127,10 @@ def grdcontour(self, grid, **kwargs): """ kwargs = self._preprocess(**kwargs) - # Specify levels for contours or annotations + # Specify levels for contours or annotations. # One level is converted to a string with a trailing comma to separate it from - # specifying an interval - # Multiple levels are concatenated to a comma-separated string + # specifying an interval. + # Multiple levels are concatenated to a comma-separated string. for arg in ["A", "C"]: if is_nonstr_iter(kwargs.get(arg)): if len(kwargs[arg]) == 1: # One level From 7ade30175d92ef99396df0a1c1ff9ca6924eb8c4 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 26 Apr 2024 14:04:48 +0200 Subject: [PATCH 31/39] Add periods --- pygmt/src/grdcontour.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pygmt/src/grdcontour.py b/pygmt/src/grdcontour.py index 0f4538f46cb..629fdc4685f 100644 --- a/pygmt/src/grdcontour.py +++ b/pygmt/src/grdcontour.py @@ -51,17 +51,17 @@ def grdcontour(self, grid, **kwargs): Specify the contour lines to generate. - The file name of a CPT file where the color boundaries will be used as - contour levels + contour levels. - The file name of a 2 (or 3) column file containing the contour levels (col 0), - (**C**)ontour or (**A**)nnotate (col 1), and optional angle (col 2) - - A fixed contour interval - - A list of contour levels + (**C**)ontour or (**A**)nnotate (col 1), and optional angle (col 2). + - A fixed contour interval. + - A list of contour levels. annotation : float, list, or str Specify or disable annotated contour levels, modifies annotated contours specified in ``interval``. - - Specify a fixed annotation interval - - Specify a list of annotation levels + - Specify a fixed annotation interval. + - Specify a list of annotation levels. - Disable all annotations by setting ``annotation="n"``. - Adjust the appearance by appending different modifiers, e.g., ``"annot_int+f10p+gred"`` gives annotations with a font size of 10 points From cb6871bcb9907afcd8af69168b92c880a3e081e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Sat, 27 Apr 2024 14:44:16 +0200 Subject: [PATCH 32/39] Add code for backward-compatibility regarding 'sequence_plus' Co-authored-by: Dongdong Tian --- pygmt/src/grdcontour.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pygmt/src/grdcontour.py b/pygmt/src/grdcontour.py index 629fdc4685f..ed19b95a2ac 100644 --- a/pygmt/src/grdcontour.py +++ b/pygmt/src/grdcontour.py @@ -126,6 +126,19 @@ def grdcontour(self, grid, **kwargs): >>> fig.show() """ kwargs = self._preprocess(**kwargs) + + # Backward compatibility with the old syntax like (100, "e", "f10p", "gred"). + if is_nonstr_iter(kwargs.get("A")) and any( + i[0] in "acdefgijlLnoprtuvwx=" for i in kwargs("A") if isinstance(i, str) + ): + msg = ( + "Argument of the parameter 'annotation'/'A' is using the old, deprecated " + "syntax. Please refer to the PyGMT documentation for the new syntax. " + "The warning will be removed in v0.14.0 and the old syntax will no longer " + "be supported. " + ) + warnings.warn(msg, catalog=FutureWarning, stacklevel=2) + kwargs["A"] = "+".join(f"{item}" for item in kwargs["A"]) # Specify levels for contours or annotations. # One level is converted to a string with a trailing comma to separate it from From e25e9edb63b106904c587ec05d4dafb5ac6f9aa9 Mon Sep 17 00:00:00 2001 From: actions-bot <58130806+actions-bot@users.noreply.github.com> Date: Sat, 27 Apr 2024 12:47:47 +0000 Subject: [PATCH 33/39] [format-command] fixes --- pygmt/src/grdcontour.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/grdcontour.py b/pygmt/src/grdcontour.py index ed19b95a2ac..f8b3c97d1a1 100644 --- a/pygmt/src/grdcontour.py +++ b/pygmt/src/grdcontour.py @@ -126,7 +126,7 @@ def grdcontour(self, grid, **kwargs): >>> fig.show() """ kwargs = self._preprocess(**kwargs) - + # Backward compatibility with the old syntax like (100, "e", "f10p", "gred"). if is_nonstr_iter(kwargs.get("A")) and any( i[0] in "acdefgijlLnoprtuvwx=" for i in kwargs("A") if isinstance(i, str) From 7fee937fcad2425497267d39f2ea1009ffa68eb0 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 27 Apr 2024 15:20:25 +0200 Subject: [PATCH 34/39] Import warinings --- pygmt/src/grdcontour.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pygmt/src/grdcontour.py b/pygmt/src/grdcontour.py index f8b3c97d1a1..31b669981e9 100644 --- a/pygmt/src/grdcontour.py +++ b/pygmt/src/grdcontour.py @@ -2,6 +2,8 @@ grdcontour - Plot a contour figure. """ +import warnings + from pygmt.clib import Session from pygmt.helpers import ( build_arg_list, From be21572284b1a698cf03d2ca7418b213642f8c0c Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 27 Apr 2024 15:46:17 +0200 Subject: [PATCH 35/39] Use square instead of round brakets --- pygmt/src/grdcontour.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/grdcontour.py b/pygmt/src/grdcontour.py index 31b669981e9..12148cab44f 100644 --- a/pygmt/src/grdcontour.py +++ b/pygmt/src/grdcontour.py @@ -131,7 +131,7 @@ def grdcontour(self, grid, **kwargs): # Backward compatibility with the old syntax like (100, "e", "f10p", "gred"). if is_nonstr_iter(kwargs.get("A")) and any( - i[0] in "acdefgijlLnoprtuvwx=" for i in kwargs("A") if isinstance(i, str) + i[0] in "acdefgijlLnoprtuvwx=" for i in kwargs["A"] if isinstance(i, str) ): msg = ( "Argument of the parameter 'annotation'/'A' is using the old, deprecated " From a05ec74ec721dc56bb6cf2f07d2627e60247f632 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 27 Apr 2024 17:19:46 +0200 Subject: [PATCH 36/39] Add test for old syntax of 'annotations' parameter --- pygmt/src/grdcontour.py | 3 ++- pygmt/tests/test_grdcontour.py | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/pygmt/src/grdcontour.py b/pygmt/src/grdcontour.py index 12148cab44f..80ef7d75ab1 100644 --- a/pygmt/src/grdcontour.py +++ b/pygmt/src/grdcontour.py @@ -129,7 +129,8 @@ def grdcontour(self, grid, **kwargs): """ kwargs = self._preprocess(**kwargs) - # Backward compatibility with the old syntax like (100, "e", "f10p", "gred"). + # Backward compatibility with the old syntax for annotations like + # [100, "e", "f10p", "gred"]. if is_nonstr_iter(kwargs.get("A")) and any( i[0] in "acdefgijlLnoprtuvwx=" for i in kwargs["A"] if isinstance(i, str) ): diff --git a/pygmt/tests/test_grdcontour.py b/pygmt/tests/test_grdcontour.py index cfcfdbe2752..6ea4dc3de11 100644 --- a/pygmt/tests/test_grdcontour.py +++ b/pygmt/tests/test_grdcontour.py @@ -47,6 +47,23 @@ def test_grdcontour_one_level(grid): return fig +@pytest.mark.mpl_image_compare(filename="test_grdcontour_one_level.png") +def test_grdcontour_old_annotations(grid): + """ + Test the old syntax for the annotations parameter using "sequence_plus". + Modified from the "test_grdcontour_one_level()" test. Can be removed in v0.14.0. + """ + fig = Figure() + fig.grdcontour( + grid=grid, + interval=[400], + annotation=[570, "pblack"], + projection="M10c", + frame=True, + ) + return fig + + @pytest.mark.mpl_image_compare def test_grdcontour_multiple_levels(grid): """ From fedf60d8ab7b8c8e5c65d3ffa65eadf26c87dbe7 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 27 Apr 2024 17:26:08 +0200 Subject: [PATCH 37/39] Fix keyword of 'warnings.warn' from 'catalog' to 'category' --- pygmt/src/grdcontour.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/grdcontour.py b/pygmt/src/grdcontour.py index 80ef7d75ab1..a63befaaf9a 100644 --- a/pygmt/src/grdcontour.py +++ b/pygmt/src/grdcontour.py @@ -140,7 +140,7 @@ def grdcontour(self, grid, **kwargs): "The warning will be removed in v0.14.0 and the old syntax will no longer " "be supported. " ) - warnings.warn(msg, catalog=FutureWarning, stacklevel=2) + warnings.warn(msg, category=FutureWarning, stacklevel=2) kwargs["A"] = "+".join(f"{item}" for item in kwargs["A"]) # Specify levels for contours or annotations. From 6c53454f9dd0ee229f5600037752b6019c3cf404 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 27 Apr 2024 17:36:20 +0200 Subject: [PATCH 38/39] Adjust test to reuse baseline image --- pygmt/tests/test_grdcontour.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/tests/test_grdcontour.py b/pygmt/tests/test_grdcontour.py index 6ea4dc3de11..502f10bfb03 100644 --- a/pygmt/tests/test_grdcontour.py +++ b/pygmt/tests/test_grdcontour.py @@ -57,7 +57,7 @@ def test_grdcontour_old_annotations(grid): fig.grdcontour( grid=grid, interval=[400], - annotation=[570, "pblack"], + annotation=["570,", "gwhite"], projection="M10c", frame=True, ) From 574c4a7a808fd60b1b1d49b53c066180ac8e2523 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 27 Apr 2024 18:18:23 +0200 Subject: [PATCH 39/39] Fix typos --- pygmt/src/grdcontour.py | 4 ++-- pygmt/tests/test_grdcontour.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pygmt/src/grdcontour.py b/pygmt/src/grdcontour.py index a63befaaf9a..8a6db2715e7 100644 --- a/pygmt/src/grdcontour.py +++ b/pygmt/src/grdcontour.py @@ -129,7 +129,7 @@ def grdcontour(self, grid, **kwargs): """ kwargs = self._preprocess(**kwargs) - # Backward compatibility with the old syntax for annotations like + # Backward compatibility with the old syntax for the annotation parameter, e.g., # [100, "e", "f10p", "gred"]. if is_nonstr_iter(kwargs.get("A")) and any( i[0] in "acdefgijlLnoprtuvwx=" for i in kwargs["A"] if isinstance(i, str) @@ -143,7 +143,7 @@ def grdcontour(self, grid, **kwargs): warnings.warn(msg, category=FutureWarning, stacklevel=2) kwargs["A"] = "+".join(f"{item}" for item in kwargs["A"]) - # Specify levels for contours or annotations. + # Specify levels for the annotation and interval parameters. # One level is converted to a string with a trailing comma to separate it from # specifying an interval. # Multiple levels are concatenated to a comma-separated string. diff --git a/pygmt/tests/test_grdcontour.py b/pygmt/tests/test_grdcontour.py index 502f10bfb03..33fd04bdd0c 100644 --- a/pygmt/tests/test_grdcontour.py +++ b/pygmt/tests/test_grdcontour.py @@ -50,7 +50,7 @@ def test_grdcontour_one_level(grid): @pytest.mark.mpl_image_compare(filename="test_grdcontour_one_level.png") def test_grdcontour_old_annotations(grid): """ - Test the old syntax for the annotations parameter using "sequence_plus". + Test the old syntax for the annotation parameter using "sequence_plus". Modified from the "test_grdcontour_one_level()" test. Can be removed in v0.14.0. """ fig = Figure()