-
Notifications
You must be signed in to change notification settings - Fork 235
Add a gallery example showing different vector heads and tails #890
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 24 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
525b1f9
Create vectors.py
michaelgrund 8479e60
formatting etc.
michaelgrund 7342953
adjustments
michaelgrund df29128
Merge branch 'master' into michaelgrund-example-vectors
michaelgrund fbc2866
modified docs
michaelgrund 153a92d
Merge branch 'michaelgrund-example-vectors' of https://github.com/Gen…
michaelgrund 07820ee
corrected typos
michaelgrund 7b468df
added example showing different vector heads and tails
michaelgrund 0702083
Merge branch 'master' into michaelgrund-example-vectors
michaelgrund b44f1b0
formatting
michaelgrund 6341270
corrected typo
michaelgrund df61c9c
Merge branch 'master' into michaelgrund-example-vectors
michaelgrund 5aaac63
Update examples/gallery/line/vector-heads-tails.py
michaelgrund 510e25d
Merge branch 'master' into michaelgrund-example-vectors
michaelgrund 46f59d5
modifications based on review
michaelgrund c07ffb7
added Meghans suggestion
michaelgrund 4e56a16
Merge branch 'master' into michaelgrund-example-vectors
michaelgrund 7d38f41
some formatting
michaelgrund 65520a6
formatting theta
michaelgrund a2f0ede
formatting theta
michaelgrund c759181
removed theta
michaelgrund 3252005
Update examples/gallery/line/vector-heads-tails.py
michaelgrund b6d065c
Update examples/gallery/line/vector-heads-tails.py
michaelgrund 4242351
Merge branch 'master' into michaelgrund-example-vectors
michaelgrund 0cb0438
Update examples/gallery/line/vector-heads-tails.py
michaelgrund 77bc3be
Merge branch 'master' into michaelgrund-example-vectors
michaelgrund c4d4ad9
updates based on review
michaelgrund 3877278
Update examples/gallery/line/vector-heads-tails.py
michaelgrund e8bdc83
Update examples/gallery/line/vector-heads-tails.py
michaelgrund 847b408
removed trailing white spaces
michaelgrund 0b4d158
Merge branch 'master' into michaelgrund-example-vectors
seisman 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,78 @@ | ||
| """ | ||
| Vector heads and tails | ||
| ---------------------- | ||
|
|
||
| Many modules in PyGMT allow to plot vectors with individual | ||
| heads and tails. For this purpose, several modifiers may be appended to | ||
| the corresponding vector-producing parameters for specifying the placement | ||
| of vector heads and tails, their shapes, and the justification of the vector. | ||
|
|
||
| To place a vector head at the beginning of the vector path | ||
| simply append **+b** to the vector-producing option (use **+e** to place | ||
michaelgrund marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| one at the end). Optionally, append **t** for a terminal line, **c** for a | ||
| circle, **a** for arrow (default), **i** for tail, **A** for plain open | ||
| arrow, and **I** for plain open tail. Further append **+l** or **+r** to | ||
| only draw the left or right half-sides of the selected head/tail | ||
michaelgrund marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| (default is both sides). In this context left and right refers to the side of | ||
| the vector line when viewed from the beginning point to the end point of a | ||
| line segment. The angle of the vector head apex can be set using | ||
| **+a**\ *angle* (default is 30). The shape of the vector head can be adjusted | ||
| using **+h**\ *shape* (e.g. ``+h0.5``). | ||
|
|
||
| For further modifiers see the *Vector Attributes* subsection of the | ||
| corresponding module. | ||
|
|
||
| In the following we use the :meth:`pygmt.Figure.plot` method to plot vectors | ||
| with individual heads and tails. We must specify the modifiers (together with | ||
| the vector type, here ``v``) by passing the corresponding shortcuts to the | ||
| ``style`` parameter. | ||
|
|
||
| """ | ||
|
|
||
| import pygmt | ||
|
|
||
| fig = pygmt.Figure() | ||
| fig.basemap( | ||
| region=[0, 10, 0, 15], projection="X15c/10c", frame='+t"Vector heads and tails"' | ||
| ) | ||
|
|
||
| x = 1 | ||
| y = 14 | ||
| angle = 0 # in degrees, measured counter-clockwise from horizontal | ||
| length = 7 | ||
|
|
||
| for vecstyle in [ | ||
| # vector without head and tail (line) | ||
| "v0c", | ||
| # plain open arrow at beginning and end, angle of the vector head apex is set to 50 | ||
| "v0.6c+bA+eA+a50", | ||
| # plain open tail at beginning and end | ||
| "v0.4c+bI+eI", | ||
| # terminal line at beginning and end, angle of vector head apex is set to 80 | ||
| "v0.3c+bt+et+a80", | ||
| # arrow head at end | ||
| "v0.6c+e", | ||
| # circle at beginning and arrow head at end | ||
| "v0.6c+bc+ea", | ||
| # terminal line at beginning and arrow head at end | ||
| "v0.6c+bt+ea", | ||
| # arrow head at end, shape of vector head is set to 0.5 | ||
| "v1c+e+h0.5", | ||
| # modified arrow heads at beginning and end | ||
| "v1c+b+e+h0.5", | ||
| # tail at beginning and arrow with modified vector head at end | ||
| "v1c+bi+ea+h0.5", | ||
| # half-sided arrow head (right side) at beginning and arrow at the end | ||
| "v1c+bar+ea+h0.8", | ||
| # half-sided arrow heads at beginning (right side) and end (left side) | ||
| "v1c+bar+eal+h0.5", | ||
| # half-sided tail at beginning and arrow at end (right side for both) | ||
| "v1c+bi+ea+r+h0.5+a45", | ||
| ]: | ||
| fig.plot( | ||
| x=x, y=y, style=vecstyle, direction=([angle], [length]), pen="2p", color="red3" | ||
| ) | ||
| fig.text(x=6, y=y, text=vecstyle, justify="ML", offset="0.2c/0c") | ||
michaelgrund marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| y -= 1 # move the next vector down | ||
|
|
||
| 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.