Skip to content

Commit 80caf3d

Browse files
DOC: Update gallery example for Figure.solar (#3858)
1 parent d44a40f commit 80caf3d

File tree

1 file changed

+25
-40
lines changed

1 file changed

+25
-40
lines changed
Lines changed: 25 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
"""
2-
Day-night terminator line and twilights
3-
=======================================
2+
Day-night terminator and twilights
3+
==================================
44
5-
Use :meth:`pygmt.Figure.solar` to show the different transition stages between
6-
daytime and nighttime. The parameter ``terminator`` is used to set the twilight
7-
stage, and can be either ``"day_night"`` (brightest), ``"civil"``,
8-
``"nautical"``, or ``"astronomical"`` (darkest).
9-
Refer to https://en.wikipedia.org/wiki/Twilight for more information.
5+
Use :meth:`pygmt.Figure.solar` to show the different transition stages between daytime
6+
and nighttime. The parameter ``terminator`` is used to set the twilight stage, and can
7+
be either ``"day_night"`` (brightest), ``"civil"``, ``"nautical"``, or
8+
``"astronomical"`` (darkest). Refer to https://en.wikipedia.org/wiki/Twilight for more
9+
information.
1010
"""
1111

1212
# %%
@@ -15,39 +15,24 @@
1515
import pygmt
1616

1717
fig = pygmt.Figure()
18-
# Create a figure showing the global region on a Mollweide projection
19-
# Land color is set to dark green and water color is set to light blue
20-
fig.coast(region="d", projection="W0/15c", land="darkgreen", water="lightblue")
21-
# Set a time for the day-night terminator and twilights, 17:00 UTC on
22-
# January 1, 2000
23-
terminator_datetime = datetime.datetime(
18+
# Create a global map using the Mollweide projection, centered at 0°E, with a width of
19+
# 15 centimeters.
20+
fig.basemap(region="d", projection="W15c", frame=True)
21+
fig.coast(land="darkgreen", water="lightblue")
22+
23+
# Set a time for the day-night terminator and twilights to 17:00 UTC on January 1, 2000
24+
reference_time = datetime.datetime(
2425
year=2000, month=1, day=1, hour=17, minute=0, second=0
2526
)
26-
# Set the pen line to be 0.5 points thick
27-
# Set the fill for the night area to be navy blue at different transparency
28-
# levels
29-
fig.solar(
30-
terminator="day_night",
31-
terminator_datetime=terminator_datetime,
32-
fill="navyblue@95",
33-
pen="0.5p",
34-
)
35-
fig.solar(
36-
terminator="civil",
37-
terminator_datetime=terminator_datetime,
38-
fill="navyblue@85",
39-
pen="0.5p",
40-
)
41-
fig.solar(
42-
terminator="nautical",
43-
terminator_datetime=terminator_datetime,
44-
fill="navyblue@80",
45-
pen="0.5p",
46-
)
47-
fig.solar(
48-
terminator="astronomical",
49-
terminator_datetime=terminator_datetime,
50-
fill="navyblue@80",
51-
pen="0.5p",
52-
)
27+
28+
# Plot the day-night terminator and twilights
29+
for terminator in ["day_night", "civil", "nautical", "astronomical"]:
30+
fig.solar(
31+
terminator=terminator,
32+
terminator_datetime=reference_time,
33+
# Set the fill for the night area to navy blue with 85 % transparency
34+
fill="navyblue@85",
35+
pen="0.5p", # Set the outline to be 0.5 points thick
36+
)
37+
5338
fig.show()

0 commit comments

Comments
 (0)