Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add inline example for colorbar #2373

Merged
merged 9 commits into from
Mar 23, 2023
19 changes: 19 additions & 0 deletions pygmt/src/colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -119,6 +121,23 @@ def colorbar(self, **kwargs):
{panel}
{perspective}
{transparency}

Example
-------
>>> import pygmt
>>> # 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)
>>> # Call the colorbar method for the plot
>>> fig.colorbar(
... # Set cmap to the "roma" CPT
... cmap="roma",
... # Label the x-axis "Velocity" and the y-axis "m/s"
... frame=["x+lVelocity", "y+lm/s"],
... )
>>> # Show the plot
>>> fig.show()
"""
kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access
with Session() as lib:
Expand Down