Skip to content

Figure.fill_between: Support for non-coregistered curves#4692

Merged
seisman merged 2 commits into
mainfrom
fill_between/non-co-registrated
Jun 24, 2026
Merged

Figure.fill_between: Support for non-coregistered curves#4692
seisman merged 2 commits into
mainfrom
fill_between/non-co-registrated

Conversation

@seisman

@seisman seisman commented Jun 21, 2026

Copy link
Copy Markdown
Member

Now support two curves with different x-coodinates.

Related to #4678 and #4679

Preview: https://pygmt-dev--4692.org.readthedocs.build/en/4692/api/generated/pygmt.Figure.fill_between.html

Examples

import pygmt
import numpy as np

x = np.linspace(0, 4, 100)
y = np.sin(5 * x)
x3 = np.array([0, 0.21, 0.4, 0.63, 0.89, 1.18, 1.45, 1.69, 1.96, 2.26, 2.61, 3.23, 3.49, 4.0])
y3 = 0.5 * np.cos(3 * x3)

fig = pygmt.Figure()
fig.basemap(region=[0, 4, -1.2, 1.2], projection="X10c/5c", frame=True)
fig.fill_between(
    x=x,
    y=y,
    x2=x3,
    y2=y3,
    fill="lightgreen",
    fill2="lightbrown",
    pen="1p,green",
    pen2="1p,brown",
    label="y=sin(5x)",
    label2="y=0.5*cos(3x)",
)
fig.plot(x=x, y=y, style="c0.06c", fill="green", pen="green")
fig.plot(x=x3, y=y3, style="c0.06c", fill="brown", pen="brown")
fig.legend()
fig.show()
fill

@seisman seisman added enhancement Improving an existing feature needs review This PR has higher priority and needs review. labels Jun 21, 2026
@seisman seisman added this to the 0.19.0 milestone Jun 21, 2026
@github-actions

github-actions Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Summary of changed images

This is an auto-generated report of images that have changed on the DVC remote

Status Path
added pygmt/tests/baseline/test_fill_between_noncoregistered.png
modified pygmt/tests/baseline/test_fill_between_coregistered.png
modified pygmt/tests/baseline/test_fill_between_y2_scalar.png

Image diff(s)

Details

Added images

  • test_fill_between_noncoregistered.png

Modified images

Path Old New
test_fill_between_coregistered.png
test_fill_between_y2_scalar.png

Report last updated at commit 7e8cff3

@yvonnefroehlich yvonnefroehlich left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

I think it's nice to extend the related gallery example https://www.pygmt.org/dev/gallery/lines/fill_areas_between_curves.html using the usage of non-co-registrated curves (in a separate PR).

@seisman seisman removed the needs review This PR has higher priority and needs review. label Jun 24, 2026
@seisman seisman merged commit 84980ca into main Jun 24, 2026
23 of 24 checks passed
@seisman seisman deleted the fill_between/non-co-registrated branch June 24, 2026 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Improving an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants