Skip to content

Commit d03862b

Browse files
Add inline example for colorbar (#2373)
Co-authored-by: Dongdong Tian <[email protected]>
1 parent cee93a4 commit d03862b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

pygmt/src/colorbar.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
from pygmt.clib import Session
66
from pygmt.helpers import build_arg_string, fmt_docstring, kwargs_to_strings, use_alias
77

8+
__doctest_skip__ = ["colorbar"]
9+
810

911
@fmt_docstring
1012
@use_alias(
@@ -119,6 +121,23 @@ def colorbar(self, **kwargs):
119121
{panel}
120122
{perspective}
121123
{transparency}
124+
125+
Example
126+
-------
127+
>>> import pygmt
128+
>>> # Create a new figure instance with pygmt.Figure()
129+
>>> fig = pygmt.Figure()
130+
>>> # Create a basemap
131+
>>> fig.basemap(region=[0, 10, 0, 3], projection="X10c/3c", frame=True)
132+
>>> # Call the colorbar method for the plot
133+
>>> fig.colorbar(
134+
... # Set cmap to the "roma" CPT
135+
... cmap="roma",
136+
... # Label the x-axis "Velocity" and the y-axis "m/s"
137+
... frame=["x+lVelocity", "y+lm/s"],
138+
... )
139+
>>> # Show the plot
140+
>>> fig.show()
122141
"""
123142
kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access
124143
with Session() as lib:

0 commit comments

Comments
 (0)