Skip to content

Commit

Permalink
Add inline example for solar (GenericMappingTools#2147)
Browse files Browse the repository at this point in the history
* Add inline example to the solar.py docstring

Co-authored-by: Yvonne Fröhlich <94163266+yvonnefroehlich@users.noreply.github.com>
  • Loading branch information
2 people authored and Josh Sixsmith committed Dec 21, 2022
1 parent c510015 commit 42c7e26
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions pygmt/src/solar.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from pygmt.exceptions import GMTInvalidInput
from pygmt.helpers import build_arg_string, fmt_docstring, kwargs_to_strings, use_alias

__doctest_skip__ = ["solar"]


@fmt_docstring
@use_alias(
Expand Down Expand Up @@ -62,6 +64,34 @@ def solar(self, terminator="d", terminator_datetime=None, **kwargs):
{panel}
{perspective}
{transparency}
Example
-------
>>> # import the Python module "datetime"
>>> import datetime
>>> import pygmt
>>> # create a datetime object at 8:52:18 on June 24, 1997 (time in UTC)
>>> date = datetime.datetime(
... year=1997, month=6, day=24, hour=8, minute=52, second=18
... )
>>> # create a new plot with pygmt.Figure()
>>> fig = pygmt.Figure()
>>> # create a map of the Earth with the coast method
>>> fig.coast(
... land="lightgreen", water="lightblue", projection="W10c", region="d"
... )
>>> fig.solar(
... # set the terminator to "day_night"
... terminator="day_night",
... # pass the datetime object
... terminator_datetime=date,
... # fill the night-section with navyblue at 75% transparency
... fill="navyblue@75",
... # draw the terminator with a 1-point black line
... pen="1p,black",
... )
>>> # show the plot
>>> fig.show()
"""

kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access
Expand Down

0 comments on commit 42c7e26

Please sign in to comment.