-
Notifications
You must be signed in to change notification settings - Fork 228
DOC: Add basic tutorial "Plotting single-parameter symbols" #3598
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
Open
yvonnefroehlich
wants to merge
18
commits into
main
Choose a base branch
from
add-tut-symbols
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
26e48e3
Add basic tutorial for plotting symbols
yvonnefroehlich ff0ae3b
Improve docs
yvonnefroehlich a464101
Fix typo
yvonnefroehlich bdb402c
Merge branch 'main' into add-tut-symbols
yvonnefroehlich 5c43c9b
Use NumPy arrays
yvonnefroehlich 14a5b06
Improve formulation
yvonnefroehlich 530830c
Add seperate example for 'pen' and 'fill' parameters
yvonnefroehlich 8173482
Improve docs
yvonnefroehlich d2750fb
Remove 'r'
yvonnefroehlich 17b2052
Split examples for 'pen' and 'fill'
yvonnefroehlich b8ad71f
Move documentation parts again
yvonnefroehlich 0dfad73
Merge branch 'main' into add-tut-symbols
yvonnefroehlich 601446b
Fix typos
yvonnefroehlich 28b7764
Merge branch 'main' into add-tut-symbols
yvonnefroehlich d35af8b
Merge branch 'main' into add-tut-symbols
yvonnefroehlich 3d3010d
Merge branch 'main' into add-tut-symbols
yvonnefroehlich de138bb
Merge branch 'main' into add-tut-symbols
yvonnefroehlich 87962a4
Merge branch 'main' into add-tut-symbols
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,94 @@ | ||
""" | ||
Plotting symbols | ||
================ | ||
|
||
The :meth:`pygmt.Figure.plot` method can plot symbols via the ``style``, | ||
``size``, and ``symbol`` parameters. | ||
""" | ||
|
||
# %% | ||
import pygmt | ||
|
||
# Set up five sample data points as lists for the x and y values | ||
x = [-4, -2, 0, 2, 4] | ||
y = [0] * len(x) | ||
|
||
|
||
# %% | ||
# Use the ``style`` parameter of the :meth:`pygmt.Figure.plot` method to plot all data | ||
# points with the same symbol and size. Via the ``fill`` parameter the symbols can be | ||
# filled with a color or pattern, and ``pen`` can add an outline (pass an argument in | ||
# the form *width*,\ *color*,\ *style*). The defaults are no fill and a 0.25-points | ||
# thick, black, solid outline. | ||
|
||
fig = pygmt.Figure() | ||
fig.basemap(region=[-5, 5, -2, 2], projection="X10c/4c", frame=True) | ||
|
||
# Plot circles (first "c") with a diameter of 0.5 centimeters (second "c") | ||
fig.plot(x=x, y=y, style="c0.5c", fill="gray", pen="1p,orange") | ||
|
||
fig.show() | ||
|
||
|
||
# %% | ||
# Use the ``size`` parameter to plot the data points with individual sizes. | ||
|
||
fig = pygmt.Figure() | ||
fig.basemap(region=[-5, 5, -2, 2], projection="X10c/4c", frame=True) | ||
|
||
fig.plot( | ||
x=x, | ||
y=y, | ||
# Plot circles (first "c") with a diameter in centimeters (second "c") | ||
style="cc", | ||
# Individual sizes | ||
size=[0.5, 0.2, 0.4, 0.6, 0.3], | ||
fill="gray", | ||
pen="1p,orange", | ||
) | ||
|
||
fig.show() | ||
|
||
|
||
# %% | ||
# Use the ``symbol`` parameter to plot the data points with individual symbols. | ||
|
||
fig = pygmt.Figure() | ||
fig.basemap(region=[-5, 5, -2, 2], projection="X10c/4c", frame=True) | ||
|
||
fig.plot( | ||
x=x, | ||
y=y, | ||
# Constant size of 0.5 centimeters | ||
style="0.5c", | ||
# Plot a circle, a square, a triangle, a inverse triangle, a diamond | ||
symbol=["c", "s", "t", "i", "d"], | ||
fill="gray", | ||
pen="1p,orange", | ||
) | ||
|
||
fig.show() | ||
|
||
|
||
# %% | ||
# Use the ``symbol`` and ``size`` parameters together to plot the data points with | ||
# individual symbols and sizes. ``symbol`` and ``size`` need to have the same length. | ||
# The unit used by ``size`` is now set via the GMT default parameter | ||
# ``PROJ_LENGTH_UNIT`` and is by default centimeters. Use :class:`pygmt.config` | ||
# to change this. | ||
|
||
fig = pygmt.Figure() | ||
fig.basemap(region=[-5, 5, -2, 2], projection="X10c/4c", frame=True) | ||
|
||
fig.plot( | ||
x=x, | ||
y=y, | ||
symbol=["c", "s", "t", "i", "d"], | ||
size=[0.5, 0.2, 0.4, 0.6, 0.3], | ||
fill="gray", | ||
pen="1p,orange", | ||
) | ||
|
||
fig.show() | ||
|
||
# sphinx_gallery_thumbnail_number = 4 |
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.