-
Notifications
You must be signed in to change notification settings - Fork 235
Add a gallery example for plotting Cartesian, circular and geographic vectors #950
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
Merged
Changes from 3 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
cef2a2d
gallery figure for plot -Sv with vectors
kmaterna 72e17c0
geo/cartesian/circ gallery example
kmaterna 2b8c406
[format-command] fixes
actions-bot 2ede9ab
editorial changes to vector example
kmaterna 93a138e
[format-command] fixes
actions-bot 2f1440f
simplifying changes
kmaterna 0b905d7
np array construction for vector example
kmaterna 9a5e866
[format-command] fixes
actions-bot bb7ac0e
Update examples/gallery/plot/vectors.py comments
kmaterna c6c5e71
Update examples/gallery/plot/vectors.py remove for loop
kmaterna d4d8e84
Update examples/gallery/plot/vectors.py
kmaterna 1b09288
moving vectors to line gallery
kmaterna 56e8436
Merge branch 'master' into gallery_vectors
seisman 3115efa
[format-command] fixes
actions-bot e4a09b6
Merge branch 'master' into gallery_vectors
seisman 0b22dee
Update examples/gallery/line/vectors.py line reorder
kmaterna 6a22200
Update examples/gallery/line/vectors.py comment added
kmaterna 7fc33a2
Update examples/gallery/line/vectors.py
kmaterna 70698d2
Update examples/gallery/line/vectors.py
kmaterna ab484e0
Update examples/gallery/line/vectors.py
kmaterna 5bdb296
documentation improvements for vector heads
kmaterna 1efe495
[format-command] fixes
actions-bot 220f4f9
Update examples/gallery/line/vectors.py
kmaterna a5311a5
Update vectors.py doc linking functions
kmaterna 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 @@ | ||
| """ | ||
| Vectors | ||
| ------ | ||
|
|
||
| The :meth:`pygmt.Figure.plot` method can plot cartesian, circular, and geographic vectors. | ||
seisman marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| The `style` parameter controls vector attributes as in GMT6 | ||
seisman marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| """ | ||
| import numpy as np | ||
| import pygmt | ||
|
|
||
| # Create a plot with 15x15 cm basemap, Mercator projection (M) over the continental US | ||
seisman marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| region = [-127, -64, 24, 53] | ||
| fig = pygmt.Figure() | ||
| fig.coast(region=region, projection="M15c", B="10.0", N="1", A="4000", W="0.25p,black") | ||
seisman marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| # plot math angle arcs with different radii | ||
| x = -110 | ||
| y = 37 | ||
| startdir = 90 | ||
| stopdir = 180 | ||
seisman marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| radius = 1.8 | ||
| pen = "1.5p,black" | ||
| arcstyles = np.repeat("m0.5c+ea", 7) | ||
| for arcstyle in arcstyles: | ||
| data = np.array([[x, y, radius, startdir, stopdir]]) | ||
| fig.plot(data=data, style=arcstyle, color="red3", pen=pen) | ||
| stopdir += 40 | ||
| radius -= 0.2 | ||
seisman marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| fig.text(text="CIRCULAR", x=-112, y=44.2, font="13p,Helvetica-Bold,black", fill="white") | ||
|
|
||
|
|
||
| # plot cartesian vectors with different lengths | ||
| x = np.linspace(-100, -100, 12) # x vector coordinates | ||
| y = np.linspace(33, 42.5, 12) # y vector coordinates | ||
| xvec = np.linspace(1, 5, 12) # dx vector data | ||
| yvec = np.zeros(np.shape(y)) # dy vector data | ||
| style = "v0.2+e+a40+gred+h0+p1p,red+z0.35" | ||
| pen = "1.0p,red" | ||
| fig.plot(x=x, y=y, style=style, pen=pen, direction=[xvec, yvec]) | ||
| fig.text(text="CARTESIAN", x=-95, y=44.2, font="13p,Helvetica-Bold,red", fill="white") | ||
seisman marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| # plot geographic vectors using endpoints | ||
| NYC = [-74.0060, 40.7128] | ||
| CHI = [-87.6298, 41.8781] | ||
| SEA = [-122.3321, 47.6062] | ||
| NO = [-90.0715, 29.9511] | ||
| style = "=0.5+e+a30+gblue+h0.5+p1p,blue+s" # = for geographic coordinates, +s for coord end points | ||
kmaterna marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| pen = "1.0p,blue" | ||
| data = np.array([[NYC[0], NYC[1], CHI[0], CHI[1]]]) | ||
| data = np.vstack((data, np.array([[NYC[0], NYC[1], SEA[0], SEA[1]]]))) | ||
| data = np.vstack((data, np.array([[NYC[0], NYC[1], NO[0], NO[1]]]))) | ||
seisman marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| fig.plot(data=data, style=style, pen=pen) | ||
| fig.text( | ||
| text="GEOGRAPHIC", x=-74.5, y=44.2, font="13p,Helvetica-Bold,blue", fill="white" | ||
| ) | ||
| fig.show() | ||
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.