Skip to content
Merged
Changes from 7 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2841904
Add first version of curves_area galley example
yvonnefroehlich Apr 14, 2024
8a85475
[format-command] fixes
actions-bot Apr 14, 2024
35506d6
Merge branch 'main' into add-gallery-area-curves
yvonnefroehlich Apr 18, 2024
af04674
Merge branch 'main' into add-gallery-area-curves
yvonnefroehlich Apr 9, 2026
c3427da
Merge branch 'main' into add-gallery-area-curves
yvonnefroehlich Apr 9, 2026
20d6c08
Merge branch 'main' into add-gallery-area-curves
yvonnefroehlich Apr 10, 2026
0ff0c19
Use new parameter name
yvonnefroehlich Apr 10, 2026
9548c89
Simply creating of pandas dataframe
yvonnefroehlich Apr 10, 2026
7b179aa
Adjust intro text
yvonnefroehlich Apr 10, 2026
aee5fbf
Improve title
yvonnefroehlich Apr 10, 2026
1ee9c27
Fix typo
yvonnefroehlich Apr 10, 2026
8ddc317
Remove seperation line
yvonnefroehlich Apr 10, 2026
784bcfc
Improve structure
yvonnefroehlich Apr 10, 2026
805f0d6
Extend intro text
yvonnefroehlich Apr 10, 2026
629f5b8
Add comparision with horizontal line via +y - similar to wiggle
yvonnefroehlich Apr 10, 2026
0b222b5
Add comments
yvonnefroehlich Apr 10, 2026
87109dd
Merge branch 'main' into add-gallery-area-curves
yvonnefroehlich Apr 10, 2026
83d458d
Fix title underline
yvonnefroehlich Apr 15, 2026
a2814fb
Merge branch 'main' into add-gallery-area-curves
yvonnefroehlich Apr 15, 2026
3253389
Fix typo in method name
yvonnefroehlich Apr 15, 2026
fdb7661
Fix typo in comparison
yvonnefroehlich Apr 15, 2026
d13ca93
Do not import pygmt as gmt
yvonnefroehlich Apr 15, 2026
02db5ee
Fix grammar
yvonnefroehlich Apr 15, 2026
cddc4b9
Rewrapp to 88 chars
yvonnefroehlich Apr 16, 2026
eb28810
Make file name more descriptive
yvonnefroehlich Apr 16, 2026
a70c461
Merge branch 'main' into add-gallery-area-curves
yvonnefroehlich Apr 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions examples/gallery/lines/curves_area.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
"""
Area between curves
-------------------
Comment thread
yvonnefroehlich marked this conversation as resolved.
Outdated
Using the ``fill_between`` parameter of the :meth:`pygmt.Figure.plot` method it is
possible to fill the area between two curves y1 and y2 with color. Different fills
(colors or patterns) can be used for the areas y1 > y2 and y1 < y2. Optionally, the
curves can be drawn.
"""

# %%
import numpy as np
import pandas as pd
import pygmt as gmt

# -----------------------------------------------------------------------------
# Generate some test data and create a pandas DataFrame
x = np.arange(-10, 10.2, 0.1)
y1 = np.sin(x * 3)
y2 = np.sin(x / 2)

data = np.array([x, y1, y2])
data_tp = data.transpose()

data_df = pd.DataFrame(data_tp, columns=["x", "y1", "y2"])

Comment thread
yvonnefroehlich marked this conversation as resolved.
Outdated
# -----------------------------------------------------------------------------
# Set up new Figure instance
Comment thread
yvonnefroehlich marked this conversation as resolved.
Outdated
fig = gmt.Figure()
fig.basemap(region=[-10, 10, -5, 5], projection="X15c/5c", frame=True)

fig.plot(
data=data_df,
fill="orange",
fill_between="c+gsteelblue+lshort < long",
label="short > long",
)

fig.legend()

fig.show()


# %%
# Additionally we can draw the curves.

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

fig.plot(
data=data_df,
fill="p8",
pen="1p,black,solid",
fill_between="c+gp17+p1p,black,dashed",
)

fig.show()

# sphinx_gallery_thumbnail_number = 1
Loading