Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
26e48e3
Add basic tutorial for plotting symbols
yvonnefroehlich Nov 7, 2024
ff0ae3b
Improve docs
yvonnefroehlich Nov 8, 2024
a464101
Fix typo
yvonnefroehlich Nov 8, 2024
bdb402c
Merge branch 'main' into add-tut-symbols
yvonnefroehlich Nov 10, 2024
5c43c9b
Use NumPy arrays
yvonnefroehlich Nov 10, 2024
14a5b06
Improve formulation
yvonnefroehlich Nov 10, 2024
530830c
Add seperate example for 'pen' and 'fill' parameters
yvonnefroehlich Nov 10, 2024
8173482
Improve docs
yvonnefroehlich Nov 10, 2024
d2750fb
Remove 'r'
yvonnefroehlich Nov 10, 2024
17b2052
Split examples for 'pen' and 'fill'
yvonnefroehlich Nov 10, 2024
b8ad71f
Move documentation parts again
yvonnefroehlich Nov 10, 2024
0dfad73
Merge branch 'main' into add-tut-symbols
yvonnefroehlich Nov 12, 2024
601446b
Fix typos
yvonnefroehlich Nov 13, 2024
28b7764
Merge branch 'main' into add-tut-symbols
yvonnefroehlich Nov 24, 2024
d35af8b
Merge branch 'main' into add-tut-symbols
yvonnefroehlich Nov 28, 2024
3d3010d
Merge branch 'main' into add-tut-symbols
yvonnefroehlich Dec 24, 2024
de138bb
Merge branch 'main' into add-tut-symbols
yvonnefroehlich Jan 16, 2025
87962a4
Merge branch 'main' into add-tut-symbols
yvonnefroehlich Mar 10, 2025
cecc28f
Merge branch 'main' into add-tut-symbols
yvonnefroehlich Apr 9, 2026
85ab548
Merge branch 'main' into add-tut-symbols
yvonnefroehlich Apr 10, 2026
ac0d721
Use list instead of NumPy array
yvonnefroehlich Apr 10, 2026
bc94784
Use new line
yvonnefroehlich Apr 10, 2026
f973e07
Fix styling
seisman Apr 10, 2026
d302d9b
Merge branch 'main' into add-tut-symbols
seisman Apr 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions examples/tutorials/basics/symbols.py
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
Comment thread
yvonnefroehlich marked this conversation as resolved.
Outdated
# 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