Skip to content
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

Expand gallery example "Focal mechanisms" to use "*fill" and "pen" #2433

Merged
merged 13 commits into from
Mar 20, 2023
26 changes: 19 additions & 7 deletions examples/gallery/seismology/meca.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@
----------------

The :meth:`pygmt.Figure.meca` method can plot focal mechanisms or beachballs.
We can specify the focal mechanism nodal planes or moment tensor components as
a dictionary using the ``spec`` parameter (or they can be specified as a 1-D
or 2-D array, or within a specified file). The size of plotted beachballs can
be specified using the ``scale`` parameter.
We can specify the focal mechanism nodal planes or moment tensor components
as a dictionary using the ``spec`` parameter (or they can be specified as a
1-D or 2-D array, or within a file). The size of the beachballs can be set
using the ``scale`` parameter. The compressive and extensive quadrants can
be filled either with a color or a pattern via the ``compressionfill`` and
``extensionfill`` parameters, respectively. Use the ``pen`` parameter to
adjust the outline of the beachballs.
"""

import pygmt

fig = pygmt.Figure()

# generate a map near Washington State showing land, water, and shorelines
# Generate a map near Washington State showing land, water, and shorelines
fig.coast(
region=[-125, -122, 47, 49],
projection="M6c",
Expand All @@ -23,18 +26,27 @@
frame="a",
)

# store focal mechanism parameters in a dictionary based on the Aki & Richards
# Store focal mechanism parameters in a dictionary based on the Aki & Richards
# convention
focal_mechanism = dict(strike=330, dip=30, rake=90, magnitude=3)

# pass the focal mechanism data through the spec parameter. In addition provide
# Pass the focal mechanism data through the spec parameter. In addition provide
# scale, event location, and event depth
fig.meca(
spec=focal_mechanism,
scale="1c", # in centimeters
longitude=-124.3,
latitude=48.1,
depth=12.0,
# Fill compressive quadrants with color "gray70" (light gray)
# [Default is "black"]
compressionfill="gray70",
# Fill extensive quadrants with color "cornsilk"
# [Default is "white"]
extensionfill="cornsilk",
# Draw a 0.5 points thick dark gray ("gray30") solid outline via
# the pen parameter [Default is "0.25p,black,solid"]
pen="0.5p,gray30,solid",
)

fig.show()