Add gallery example showing how to fill the area between two curves#3168
Open
yvonnefroehlich wants to merge 17 commits intomainfrom
Open
Add gallery example showing how to fill the area between two curves#3168yvonnefroehlich wants to merge 17 commits intomainfrom
yvonnefroehlich wants to merge 17 commits intomainfrom
Conversation
Member
Author
|
/format |
This was referenced Apr 18, 2024
Member
|
Perhaps we should continue this tutorial, considering that it will definitely take some time to implement the |
Member
Author
Sounds good. But need to finish PR #3169 to add an alias for -M first. |
seisman
reviewed
Apr 10, 2026
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
seisman
reviewed
Apr 10, 2026
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
yvonnefroehlich
commented
Apr 10, 2026
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new Sphinx-Gallery example demonstrating how to fill the area between two curves using the fill_between alias for GMT’s plot -M option, including variants with curve outlines and comparison against a constant y-level.
Changes:
- Introduce a new gallery example showing
Figure.plot(fill_between=...)with separate fills/legend labels for the two regions. - Add follow-up examples demonstrating drawing both curves and filling relative to a horizontal reference line.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -0,0 +1,82 @@ | |||
| """ | |||
| Fill area between curves | |||
| ------------------------ | |||
| possible to fill the area between two curves y1 and y2. Different fills (colors or | ||
| patterns) can be used for the areas y1 > y2 and y1 < y2. Optionally, the curves can | ||
| be drawn. | ||
| To plot an anomaly along a track use :meth:`pygmt.Figure.grdlandmask` and see the |
| # %% | ||
| # Fill the areas between the two curves using the ``fill_between`` parameter. | ||
| # Use the ``fill`` parameter and the modifier **+g** for ``fill_between`` to | ||
| # set different fills for areas with y1 > y2 and y2 < y1, respectively. Use |
|
|
||
|
|
||
| # %% | ||
| # Additionally to filling the areas, we can draw the curves. Use the ``pen`` |
Comment on lines
+13
to
+16
| import numpy as np | ||
| import pandas as pd | ||
| import pygmt as gmt | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of proposed changes
This PR is converted to draft as a high-level method is planned for fill the area between two curves
-M of
plotallows to fill the area between two curves with colors or patterns. This PR addes a gallery example showing how to do this:Note the discussion regardig using
fill_betweenorbetween_fillatFigure.plot: Add alias "fill_between" for option -M #3169 (comment).
Preview: https://pygmt-dev--3168.org.readthedocs.build/en/3168/gallery/lines/curves_area.html
Slash Commands
You can write slash commands (
/command) in the first line of a comment to performspecific operations. Supported slash command is:
/format: automatically format and lint the code