Skip to content

Commit 0b222b5

Browse files
Add comments
1 parent 629f5b8 commit 0b222b5

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

examples/gallery/lines/curves_area.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,20 @@
2323

2424

2525
# %%
26-
# Fill the area between the two curves using the ``fill_between`` parameter.
26+
# Fill the areas between the two curves using the ``fill_between`` parameter.
27+
# Use the ``fill`` parameter and the modifier **+g** for ``fill_between`` to
28+
# set different fills for areas with y1 > y2 and y2 < y1, respectively. Use
29+
# the ``label`` parameter and the modifier **+l** for ``fill_between`` to
30+
# set the corresponding legend entries.
2731

2832
fig = gmt.Figure()
2933
fig.basemap(region=[-10, 10, -5, 5], projection="X15c/5c", frame=True)
3034

3135
fig.plot(
3236
data=data_df,
3337
fill="orange",
34-
fill_between="c+gsteelblue+lshort < long",
3538
label="short > long",
39+
fill_between="c+gsteelblue+lshort < long",
3640
)
3741

3842
fig.legend()
@@ -41,9 +45,10 @@
4145

4246

4347
# %%
44-
# Additionally we can draw the curves.
48+
# Additionally to filling the areas, we can draw the curves. Use the ``pen``
49+
# parameter and the modifier **+p** for ``fill_between`` to set different
50+
# lines for the two curves y1 and y2, respectively.
4551

46-
# Set up new Figure instance
4752
fig = gmt.Figure()
4853
fig.basemap(region=[-10, 10, -5, 5], projection="X15c/5c", frame=True)
4954

@@ -58,16 +63,17 @@
5863

5964

6065
# %%
61-
# Compare to a horizontal line.
66+
# To compare a curve y1 to a horizontal line, append **+y** to ``fill_between``
67+
# and give the desired y-level.
6268

63-
# Set up new Figure instance
6469
fig = gmt.Figure()
6570
fig.basemap(region=[-10, 10, -5, 5], projection="X15c/5c", frame=True)
6671

6772
fig.plot(
6873
data=data_df[["x", "y1"]],
6974
fill="p8",
7075
pen="1p,black,solid",
76+
# Define a horizontal line at y=0.42
7177
fill_between="c+gp17+p1p,black,dashed+y0.42",
7278
)
7379

0 commit comments

Comments
 (0)