Skip to content

Commit

Permalink
DOC/Gallery example "Multi-parameter symbols": Show applying a inner …
Browse files Browse the repository at this point in the history
…diameter ("+i") to a pie wedge ("w") (#3624)
  • Loading branch information
yvonnefroehlich authored Nov 19, 2024
1 parent f76d25e commit ef71a9d
Showing 1 changed file with 24 additions and 19 deletions.
43 changes: 24 additions & 19 deletions examples/gallery/symbols/multi_parameter_symbols.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
Multi-parameter symbols
=======================
The :meth:`pygmt.Figure.plot` method can plot individual multi-parameter
symbols by passing the corresponding shortcuts (**e**, **j**, **r**, **R**,
**w**) to the ``style`` parameter:
The :meth:`pygmt.Figure.plot` method can plot individual multi-parameter symbols by
passing the corresponding shortcuts (**e**, **j**, **r**, **R**, **w**) to the ``style``
parameter:
- **e**: ellipse
- **j**: rotated rectangle
Expand All @@ -18,10 +18,10 @@
import pygmt

# %%
# We can plot multi-parameter symbols using the same symbol style. We need to
# define locations (lon, lat) via the ``x`` and ``y`` parameters (scalar for
# a single symbol or 1-D list for several ones) and two or three symbol
# parameters after those shortcuts via the ``style`` parameter.
# We can plot multi-parameter symbols using the same symbol style. We need to define
# locations (lon, lat) via the ``x`` and ``y`` parameters (scalar for a single symbol or
# 1-D list for several ones) and two or three symbol parameters after those shortcuts
# via the ``style`` parameter.
#
# The multi-parameter symbols in the ``style`` parameter are defined as:
#
Expand All @@ -30,13 +30,14 @@
# - **r**: rectangle, ``width/height``
# - **R**: rounded rectangle, ``width/height/radius``
# - **w**: pie wedge, ``diameter/startdir/stopdir``, the last two arguments are
# directions given in degrees counter-clockwise from horizontal
# directions given in degrees counter-clockwise from horizontal. Append **+i** and the
# desired value to apply an inner diameter.
#
# Upper-case versions **E**, **J**, and **W** are similar to **e**, **j**, and
# **w** but expect geographic azimuths and distances.
# Upper-case versions **E**, **J**, and **W** are similar to **e**, **j**, and **w**
# but expect geographic azimuths and distances.

fig = pygmt.Figure()
fig.basemap(region=[0, 6, 0, 2], projection="x3c", frame=True)
fig.basemap(region=[0, 7, 0, 2], projection="x3c", frame=True)

# Ellipse
fig.plot(x=0.5, y=1, style="e45/3/1", fill="orange", pen="2p,black")
Expand All @@ -48,27 +49,28 @@
fig.plot(x=4.5, y=1, style="R1.25/4/0.5", fill="seagreen", pen="2p,black")
# Pie wedge
fig.plot(x=5.5, y=1, style="w2.5/45/330", fill="lightgray", pen="2p,black")
# Ring sector
fig.plot(x=6.5, y=1, style="w2.5/45/330+i1", fill="lightgray", pen="2p,black")

fig.show()

# %%
# We can also plot symbols with varying parameters via defining those values in
# a 2-D list or numpy array (``[[parameters]]`` for a single symbol or
# ``[[parameters_1],[parameters_2],[parameters_i]]`` for several ones) or using
# an appropriately formatted input file and passing it to ``data``.
# We can also plot symbols with varying parameters via defining those values in a 2-D
# list or numpy array (``[[parameters]]`` for a single symbol or
# ``[[parameters_1],[parameters_2],[parameters_i]]`` for several ones) or using an
# appropriately formatted input file and passing it to ``data``.
#
# The symbol parameters in the 2-D list or numpy array are defined as:
#
# - **e**: ellipse, ``[[lon, lat, direction, major_axis, minor_axis]]``
# - **j**: rotated rectangle, ``[[lon, lat, direction, width, height]]``
# - **r**: rectangle, ``[[lon, lat, width, height]]``
# - **R**: rounded rectangle, ``[[lon, lat, width, height, radius]]``
# - **w**: pie wedge, ``[[lon, lat, diameter, startdir, stopdir]]``, the last
# two arguments are directions given in degrees counter-clockwise from
# horizontal
# - **w**: pie wedge, ``[[lon, lat, diameter, startdir, stopdir]]``, the last two
# arguments are directions given in degrees counter-clockwise from horizontal

fig = pygmt.Figure()
fig.basemap(region=[0, 6, 0, 4], projection="x3c", frame=["xa1f0.2", "ya0.5f0.1"])
fig.basemap(region=[0, 7, 0, 4], projection="x3c", frame=["xa1f0.2", "ya0.5f0.1"])

# Ellipse
data = [[0.5, 1, 45, 3, 1], [0.5, 3, 135, 2, 1]]
Expand All @@ -85,6 +87,9 @@
# Pie wedge
data = [[5.5, 1, 2.5, 45, 330], [5.5, 3, 1.5, 60, 300]]
fig.plot(data=data, style="w", fill="lightgray", pen="2p,black")
# Ring sector
data = [[6.5, 1, 2.5, 45, 330], [6.5, 3, 1.5, 60, 300]]
fig.plot(data=data, style="w+i1", fill="lightgray", pen="2p,black")

fig.show()

Expand Down

0 comments on commit ef71a9d

Please sign in to comment.