|
2 | 2 | Cartesian, circular, and geographic vectors
|
3 | 3 | ===========================================
|
4 | 4 |
|
5 |
| -The :meth:`pygmt.Figure.plot` method can plot Cartesian, circular, and |
6 |
| -geographic vectors. The ``style`` parameter controls vector attributes. |
7 |
| -See also the :doc:`Vector attributes example </gallery/lines/vector_heads_tails>`. |
| 5 | +The :meth:`pygmt.Figure.plot` method can plot Cartesian, circular, and geographic |
| 6 | +vectors. The ``style`` parameter controls vector attributes. See also the |
| 7 | +:doc:`Vector attributes example </gallery/lines/vector_heads_tails>`. |
8 | 8 | """
|
9 | 9 |
|
10 | 10 | # %%
|
11 | 11 | import numpy as np
|
12 | 12 | import pygmt
|
13 | 13 |
|
14 |
| -# create a plot with coast, Mercator projection (M) over the continental US |
| 14 | +# Create a plot with coast, Mercator projection (M) over the continental US |
15 | 15 | fig = pygmt.Figure()
|
16 | 16 | fig.coast(
|
17 | 17 | region=[-127, -64, 24, 53],
|
|
28 | 28 | y = np.linspace(33.5, 42.5, 12) # y vector coordinates
|
29 | 29 | direction = np.zeros(x.shape) # direction of vectors
|
30 | 30 | length = np.linspace(0.5, 2.4, 12) # length of vectors
|
31 |
| -# Cartesian vectors (v) with red fill and pen (+g, +p), vector head at |
32 |
| -# end (+e), and 40 degree angle (+a) with no indentation for vector head (+h) |
| 31 | +# Cartesian vectors (v) with red fill and pen (+g, +p), vector head at the end (+e), and |
| 32 | +# 40 degree angle (+a) with no indentation for the vector head (+h) |
33 | 33 | style = "v0.2c+e+a40+gred+h0+p1p,red"
|
34 | 34 | fig.plot(x=x, y=y, style=style, pen="1p,red", direction=[direction, length])
|
35 | 35 | fig.text(text="CARTESIAN", x=-112, y=44.2, font="13p,Helvetica-Bold,red", fill="white")
|
|
44 | 44 | stopdir = 180 + 40 * np.arange(0, num) # stop direction in degrees
|
45 | 45 | # data for circular vectors
|
46 | 46 | data = np.column_stack([x, y, radius, startdir, stopdir])
|
47 |
| -arcstyle = "m0.5c+ea" # Circular vector (m) with an arrow at end |
| 47 | +arcstyle = "m0.5c+ea" # Circular vector (m) with an arrow at the end |
48 | 48 | fig.plot(data=data, style=arcstyle, fill="red3", pen="1.5p,black")
|
49 | 49 | fig.text(text="CIRCULAR", x=-95, y=44.2, font="13p,Helvetica-Bold,black", fill="white")
|
50 | 50 |
|
|
54 | 54 | CHI = [-87.6298, 41.8781]
|
55 | 55 | SEA = [-122.3321, 47.6062]
|
56 | 56 | NO = [-90.0715, 29.9511]
|
57 |
| -# `=` means geographic vectors. |
58 |
| -# With the modifier '+s', the input data should contain coordinates of start |
59 |
| -# and end points |
| 57 | +# '=' means geographic vectors. With the modifier '+s', the input data should contain |
| 58 | +# coordinates of start and end points |
60 | 59 | style = "=0.5c+s+e+a30+gblue+h0.5+p1p,blue"
|
61 | 60 | data = np.array([NYC + CHI, NYC + SEA, NYC + NO])
|
62 | 61 | fig.plot(data=data, style=style, pen="1.0p,blue")
|
|
0 commit comments