Skip to content

Commit 6d442c0

Browse files
authored
Create rot_rectangle.py
I added rot_rectangle.py to have an example showing the use of rotated rectangles (which I heavily used during my PhD to plot splitting parameters in map view).
1 parent 5ad636b commit 6d442c0

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"""
2+
Rotated rectangle using azimuth
3+
----------------
4+
5+
The :meth:`pygmt.Figure.plot` method can plot rotated rectangles based on a
6+
given azimuth (in degrees east of north) as well as length and width. We can
7+
define the required parameters in a numpy array or use an appropriately
8+
formatted input file. Such representations are often used to e.g. display
9+
results of shear-wave splitting analysis.
10+
"""
11+
12+
import pygmt
13+
import numpy as np
14+
15+
fig = pygmt.Figure()
16+
17+
# generate a basemap around Big Island (Hawai'i) showing coastlines, land, and water
18+
fig.coast(
19+
region = [-156.5, -154.5, 18.5, 20.5],
20+
projection = "M6c",
21+
land = "grey",
22+
water = "lightblue",
23+
shorelines = True,
24+
resolution = "f",
25+
frame=["x1", "y1"]
26+
)
27+
28+
# store parameters for rotated rectangle in a numpy
29+
# array (lon, lat, azimuth in degrees east of north, lenght, width)
30+
data = np.array([[-155.533, 19.757, 45, 60, 5]])
31+
32+
# pass the data to the plotting function in addition to the corresponding
33+
# style shortcut for rotated rectangles ("J") as well as set color and pen for
34+
# the rectangle
35+
fig.plot(data = data,
36+
style = "J",
37+
color = "red3",
38+
pen = "black")
39+
40+
fig.show()

0 commit comments

Comments
 (0)