From fb13cdf4f980659d97397103bccb19d7664fb7cf Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Fri, 17 Feb 2023 07:11:27 -0500 Subject: [PATCH 1/5] add colorbar example --- pygmt/src/colorbar.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pygmt/src/colorbar.py b/pygmt/src/colorbar.py index c85dcb0ce0f..3d2ffb08775 100644 --- a/pygmt/src/colorbar.py +++ b/pygmt/src/colorbar.py @@ -5,6 +5,8 @@ from pygmt.clib import Session from pygmt.helpers import build_arg_string, fmt_docstring, kwargs_to_strings, use_alias +__doctest_skip__ = ["colorbar"] + @fmt_docstring @use_alias( @@ -101,6 +103,18 @@ def colorbar(self, **kwargs): {panel} {perspective} {transparency} + + Example + ------- + >>> import pygmt + >>> # Create a new plot with pygmt.Figure() + >>> fig = pygmt.Figure() + >>> # Call the colorbar method for the plot + >>> # Set cmap to the "roma" CPT + >>> # Label the x-axis "Velocity" and the y-axis "m/s" + >>> fig.colorbar(cmap="roma", frame=["x+lVelocity", "y+lm/s"]) + >>> # Show the plot + >>> fig.show() """ kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access with Session() as lib: From aa8f35786a1741321292d77dc42be2e64b089069 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Wed, 22 Feb 2023 06:59:56 -0500 Subject: [PATCH 2/5] example fix --- pygmt/src/colorbar.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pygmt/src/colorbar.py b/pygmt/src/colorbar.py index 3d2ffb08775..fd66757a144 100644 --- a/pygmt/src/colorbar.py +++ b/pygmt/src/colorbar.py @@ -110,9 +110,15 @@ def colorbar(self, **kwargs): >>> # Create a new plot with pygmt.Figure() >>> fig = pygmt.Figure() >>> # Call the colorbar method for the plot - >>> # Set cmap to the "roma" CPT - >>> # Label the x-axis "Velocity" and the y-axis "m/s" - >>> fig.colorbar(cmap="roma", frame=["x+lVelocity", "y+lm/s"]) + >>> fig.colorbar( + ... # Set cmap to the "roma" CPT + ... cmap="roma", + ... # Set a region and projection for the plot + ... region=[0, 1, 0, 2], + ... projection="X10c", + ... # Label the x-axis "Velocity" and the y-axis "m/s" + ... frame=["x+lVelocity", "y+lm/s"], + ... ) >>> # Show the plot >>> fig.show() """ From a63b554c68ca0b6cf94feda390b814837486b777 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Sun, 19 Mar 2023 09:17:12 -0400 Subject: [PATCH 3/5] update inline example in colorbar.py --- pygmt/src/colorbar.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pygmt/src/colorbar.py b/pygmt/src/colorbar.py index fd66757a144..6df53cfd7cf 100644 --- a/pygmt/src/colorbar.py +++ b/pygmt/src/colorbar.py @@ -109,13 +109,12 @@ def colorbar(self, **kwargs): >>> import pygmt >>> # Create a new plot with pygmt.Figure() >>> fig = pygmt.Figure() + >>> # Create a basemap figure + >>> fig.basemap(region=[0, 10, 0, 3], projection="X10c/3c") >>> # Call the colorbar method for the plot >>> fig.colorbar( ... # Set cmap to the "roma" CPT ... cmap="roma", - ... # Set a region and projection for the plot - ... region=[0, 1, 0, 2], - ... projection="X10c", ... # Label the x-axis "Velocity" and the y-axis "m/s" ... frame=["x+lVelocity", "y+lm/s"], ... ) From 0732ea5d0591f8cbf452b8a85683c961721cec96 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Sun, 19 Mar 2023 17:07:30 -0400 Subject: [PATCH 4/5] Update pygmt/src/colorbar.py Co-authored-by: Dongdong Tian --- pygmt/src/colorbar.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/src/colorbar.py b/pygmt/src/colorbar.py index 6df53cfd7cf..e33295ee907 100644 --- a/pygmt/src/colorbar.py +++ b/pygmt/src/colorbar.py @@ -109,8 +109,8 @@ def colorbar(self, **kwargs): >>> import pygmt >>> # Create a new plot with pygmt.Figure() >>> fig = pygmt.Figure() - >>> # Create a basemap figure - >>> fig.basemap(region=[0, 10, 0, 3], projection="X10c/3c") + >>> # Create a basemap + >>> fig.basemap(region=[0, 10, 0, 3], projection="X10c/3c", frame=True) >>> # Call the colorbar method for the plot >>> fig.colorbar( ... # Set cmap to the "roma" CPT From 9d20379817429cd8e54fad64b662d3d318099235 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Mon, 20 Mar 2023 10:28:54 -0400 Subject: [PATCH 5/5] Update pygmt/src/colorbar.py Co-authored-by: Dongdong Tian --- pygmt/src/colorbar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/colorbar.py b/pygmt/src/colorbar.py index 0430d7eac5d..57274d0a2b9 100644 --- a/pygmt/src/colorbar.py +++ b/pygmt/src/colorbar.py @@ -125,7 +125,7 @@ def colorbar(self, **kwargs): Example ------- >>> import pygmt - >>> # Create a new plot with pygmt.Figure() + >>> # Create a new figure instance with pygmt.Figure() >>> fig = pygmt.Figure() >>> # Create a basemap >>> fig.basemap(region=[0, 10, 0, 3], projection="X10c/3c", frame=True)