-
Notifications
You must be signed in to change notification settings - Fork 244
Add gallery example showing how to fill the area between two curves #3168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+81
−0
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 8a85475
[format-command] fixes
actions-bot 35506d6
Merge branch 'main' into add-gallery-area-curves
yvonnefroehlich af04674
Merge branch 'main' into add-gallery-area-curves
yvonnefroehlich c3427da
Merge branch 'main' into add-gallery-area-curves
yvonnefroehlich 20d6c08
Merge branch 'main' into add-gallery-area-curves
yvonnefroehlich 0ff0c19
Use new parameter name
yvonnefroehlich 9548c89
Simply creating of pandas dataframe
yvonnefroehlich 7b179aa
Adjust intro text
yvonnefroehlich aee5fbf
Improve title
yvonnefroehlich 1ee9c27
Fix typo
yvonnefroehlich 8ddc317
Remove seperation line
yvonnefroehlich 784bcfc
Improve structure
yvonnefroehlich 805f0d6
Extend intro text
yvonnefroehlich 629f5b8
Add comparision with horizontal line via +y - similar to wiggle
yvonnefroehlich 0b222b5
Add comments
yvonnefroehlich 87109dd
Merge branch 'main' into add-gallery-area-curves
yvonnefroehlich 83d458d
Fix title underline
yvonnefroehlich a2814fb
Merge branch 'main' into add-gallery-area-curves
yvonnefroehlich 3253389
Fix typo in method name
yvonnefroehlich fdb7661
Fix typo in comparison
yvonnefroehlich d13ca93
Do not import pygmt as gmt
yvonnefroehlich 02db5ee
Fix grammar
yvonnefroehlich cddc4b9
Rewrapp to 88 chars
yvonnefroehlich eb28810
Make file name more descriptive
yvonnefroehlich a70c461
Merge branch 'main' into add-gallery-area-curves
yvonnefroehlich File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| """ | ||
| Area between curves | ||
| ------------------- | ||
| 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"]) | ||
|
|
||
|
yvonnefroehlich marked this conversation as resolved.
Outdated
|
||
| # ----------------------------------------------------------------------------- | ||
| # Set up new Figure instance | ||
|
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 | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.