-
Notifications
You must be signed in to change notification settings - Fork 235
Add gallery example "Scale bar" #2822
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 5 commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
d5394f2
Add basic code and documentation
yvonnefroehlich 3808564
[format-command] fixes
actions-bot 38540cb
Remove 'box'
yvonnefroehlich bbf06d2
Merge branch 'main' into add-gallery-scalebar
yvonnefroehlich 8b8bad7
Merge branch 'main' into add-gallery-scalebar
yvonnefroehlich 0851337
Expand documentation
1bec367
Update example for 'box'
yvonnefroehlich 0804898
Merge branch 'main' into add-gallery-scalebar
yvonnefroehlich 6d14f88
Merge branch 'main' into add-gallery-scalebar
yvonnefroehlich 617b715
Merge branch 'main' into add-gallery-scalebar
yvonnefroehlich 5c169a7
Fix typos
yvonnefroehlich 0875174
Merge branch 'main' into add-gallery-scalebar
yvonnefroehlich 7a5c127
Use alias 'box' for 'F'
dcd8941
Merge branch 'main' into add-gallery-scalebar
yvonnefroehlich 54e7ed3
Improve docs
yvonnefroehlich aa9fa95
Add blank line at end of file
yvonnefroehlich 19468ea
Add comments
yvonnefroehlich 9b8281c
Replace tabs by white spaces
yvonnefroehlich ec322e4
Fix rst syntax
yvonnefroehlich 019732f
Fix rst syntax
yvonnefroehlich 0981d57
Merge branch 'main' into add-gallery-scalebar
yvonnefroehlich ad63900
Improve comments, fix typos
yvonnefroehlich 9af9b1e
Better include origin of length scale
yvonnefroehlich 047d01d
Fix typo
55bbaf4
Merge branch 'main' into add-gallery-scalebar
yvonnefroehlich b7fc7da
Fix typo
7222642
Merge branch 'main' into add-gallery-scalebar
yvonnefroehlich 909678c
Improve code and docs
64c811a
Remove blank line
e6fc3a0
Improve code and docs reagarding +c
yvonnefroehlich 94c9ac4
Shorten docs
yvonnefroehlich 14a7cfd
Fix typos
yvonnefroehlich 4430223
Fix typos
yvonnefroehlich 93bcff0
Fix typos
yvonnefroehlich beaa1a6
Extend docs for position
yvonnefroehlich 937fe2e
Add docs for distance unit
yvonnefroehlich 6023891
Use 'or' consistently
yvonnefroehlich 8f29791
Fix typo
yvonnefroehlich fcf3164
Replace "|" by "or"
yvonnefroehlich 0cfdf75
Merge branch 'main' into add-gallery-scalebar
yvonnefroehlich 88baf28
Fix line length
yvonnefroehlich b08b6be
Improv
yvonnefroehlich d8065ed
Fix line length and add article
yvonnefroehlich fd504d0
Fix typo
yvonnefroehlich cf0d1a6
Improve argument passed to 'xshift'
yvonnefroehlich 1335750
Improve argument passed to 'xshift'
yvonnefroehlich 5e519ad
Improve formulation
yvonnefroehlich 311cca7
Combine subplots into one plot
yvonnefroehlich 40fd4f8
Adjust thumbnail image
yvonnefroehlich c8f27c1
Use consistently a width of 500 kilometers
yvonnefroehlich 60dea40
Reduce thickness of scale bar
yvonnefroehlich 9f73a45
Merge branch 'main' into add-gallery-scalebar
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,97 @@ | ||
| r""" | ||
| Scale bar | ||
| ========= | ||
|
|
||
| The ``map_scale`` parameter of the :meth:`pygmt.Figure.basemap` and | ||
| :meth:`pygmt.Figure.coast` methods is used to add a scale bar to a map. | ||
| This example shows how such a scale bar can be customized: | ||
|
|
||
| - position: **j**. Set the reference point by specifying a two-letter (order | ||
| independent) code, chosen from vertically **T**\(op), **M**\(iddle), or | ||
| **B**\(ottom) and horizontally **L**\(eft), **C**\(entre), or **R**\(ight). | ||
| - justify: **+j**. Set the anchor point by specifying a two-letter (order | ||
| independent) code, chosen from vertically **T**\(op), **M**\(iddle), or | ||
| **B**\(ottom) and horizontally **L**\(eft), **C**\(entre), or **R**\(ight). | ||
| - offset: **+o**\ *xoffset*/*yoffset*. Shift from ``position`` in x | ||
| (longitude) and y (latitude) directions. | ||
| - length: **+w**\ *length*. Give value and unit. | ||
| - height: :gmt-term:`MAP_SCALE_HEIGHT` | ||
| - origin on map: **+c**\ [*slon*/]\ *slat*. *slon* is only optional for | ||
| projections with constant scale along parallels. | ||
| - fancy style: **+f**. Get a scale bar that looks like train tracks. | ||
| - label: **+l**. Use another label as the unit given via **+w**. | ||
| - label alignment: **+a**. Append **t**\(op) [Default], **b**\(ottom), | ||
| **l**\(eft), or **r**\(ight). | ||
| - distance unit: **+u**. Add the distance unit to the distance values. | ||
|
|
||
| Via the ``box`` parameter a box can be added around the scale bar. | ||
| """ | ||
|
|
||
|
|
||
| # %% | ||
| import pygmt | ||
|
|
||
| # Create a new Figure instance | ||
| fig = pygmt.Figure() | ||
|
|
||
| fig.basemap( | ||
| region=[-45, -25, -15, 0], | ||
| projection="M10c", # Mercator projection with 10 centimeters width | ||
| frame=["WSne", "af"], | ||
| map_scale="jMC+w1000k", | ||
| ) | ||
|
|
||
| fig.shift_origin(xshift="+w1c") | ||
yvonnefroehlich marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| fig.basemap( | ||
| region=[-45, -25, -15, 0], | ||
| projection="M10c", | ||
| frame=["wSnE", "af"], | ||
| map_scale="jML+jBL+o1c/1c+w1000k+f+u", | ||
| ) | ||
|
|
||
| fig.show() | ||
|
|
||
| # %% | ||
| # Amazing text | ||
seisman marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| # Create a new Figure instance | ||
| fig = pygmt.Figure() | ||
|
|
||
| with pygmt.config(MAP_SCALE_HEIGHT="20p"): | ||
| fig.basemap( | ||
| region=[-45, -25, -15, 0], | ||
| projection="M10c", | ||
| frame=["WSne", "af"], | ||
| map_scale="jBL+o1c/1c+w1000k+f+lkm", | ||
| ) | ||
|
|
||
| fig.shift_origin(xshift="+w1c") | ||
yvonnefroehlich marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| fig.basemap( | ||
| region=[-45, -25, -15, 0], | ||
| projection="M10c", | ||
| frame=["wSnE", "af"], | ||
| map_scale="jBL+o1c/1c+c-35/-5+w1000k+f+lscale at 35° W and 5° S+ukm", | ||
| ) | ||
|
|
||
| fig.show() | ||
|
|
||
| # %% | ||
| # Amazing text | ||
yvonnefroehlich marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| # Create a new Figure instance | ||
| fig = pygmt.Figure() | ||
|
|
||
| fig.coast( | ||
| region=[-45, -25, -15, 0], | ||
| projection="M10c", | ||
| land="tan", | ||
| water="lightblue", | ||
| shorelines="1/0.5p,gray30", | ||
| frame=["WSne+gtan", "af"], | ||
| map_scale="jBL+o1c/1c+w1000k+f+lkm+ar", | ||
| F="+gwhite@30+p0.5p,gray30+r3p", | ||
| ) | ||
|
|
||
| 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.