|
3 | 3 | ------------------------- |
4 | 4 |
|
5 | 5 | The :meth:`pygmt.Figure.plot` method can plot individual multi-parameter |
6 | | -symbols by passing the corresponding shortcuts listed below to the ``style`` |
7 | | -parameter. Additionally, we must define the required parameters in a 2d list or |
8 | | -numpy array (``[[parameters]]`` for a single symbol or |
9 | | -``[[parameters_1],[parameters_2],[parameters_i]]`` for several ones) or use an |
10 | | -appropriately formatted input file and pass it to ``data``. |
11 | | -
|
12 | | -The following symbols are available: |
13 | | -
|
14 | | -- **e**: ellipse, ``[[lon, lat, direction, major_axis, minor_axis]]`` |
15 | | -- **j**: rotated rectangle, ``[[lon, lat, direction, width, height]]`` |
16 | | -- **r**: rectangle, ``[[lon, lat, width, height]]`` |
17 | | -- **R**: rounded rectangle, ``[[lon, lat, width, height, radius]]`` |
18 | | -- **w**: pie wedge, ``[[lon, lat, radius, startdir, stopdir]]``, the last two |
19 | | - arguments are directions given in degrees counter-clockwise from horizontal |
20 | | -
|
21 | | -Upper-case versions **E**, **J**, and **W** are similar to **e**, **j** and |
22 | | -**w** but expect geographic azimuths and distances. |
| 6 | +symbols by passing the corresponding shortcuts (**e**, **j**, **r**, **R**, |
| 7 | +**w**) to the ``style`` parameter: |
| 8 | +
|
| 9 | +- **e**: ellipse |
| 10 | +- **j**: rotated rectangle |
| 11 | +- **r**: rectangle |
| 12 | +- **R**: rounded rectangle |
| 13 | +- **w**: pie wedge |
| 14 | +
|
23 | 15 | """ |
24 | 16 |
|
| 17 | +# sphinx_gallery_thumbnail_number = 2 |
| 18 | + |
25 | 19 | import pygmt |
26 | 20 |
|
| 21 | +######################################################################################## |
| 22 | +# We can plot multi-parameter symbols using the same symbol style. We need to |
| 23 | +# define locations (lon, lat) via the ``x`` and ``y`` parameters (scalar for |
| 24 | +# a single symbol or 1d list for several ones) and two or three symbol |
| 25 | +# parameters after those shortcuts via the ``style`` parameter. |
| 26 | +# |
| 27 | +# The multi-parameter symbols in the ``style`` parameter are defined as: |
| 28 | +# |
| 29 | +# - **e**: ellipse, ``direction/major_axis/minor_axis`` |
| 30 | +# - **j**: rotated rectangle, ``direction/width/height`` |
| 31 | +# - **r**: rectangle, ``width/height`` |
| 32 | +# - **R**: rounded rectangle, ``width/height/radius`` |
| 33 | +# - **w**: pie wedge, ``radius/startdir/stopdir``, the last two arguments are |
| 34 | +# directions given in degrees counter-clockwise from horizontal |
| 35 | +# |
| 36 | +# Upper-case versions **E**, **J**, and **W** are similar to **e**, **j** and |
| 37 | +# **w** but expect geographic azimuths and distances. |
| 38 | + |
27 | 39 | fig = pygmt.Figure() |
28 | 40 | fig.basemap(region=[0, 6, 0, 2], projection="x3c", frame=True) |
29 | 41 |
|
30 | | -# ELLIPSE |
31 | | -data = [[0.5, 1, 45, 3, 1]] |
32 | | -fig.plot(data=data, style="e", color="orange", pen="2p,black") |
| 42 | +# Ellipse |
| 43 | +fig.plot(x=0.5, y=1, style="e45/3/1", color="orange", pen="2p,black") |
| 44 | +# Rotated rectangle |
| 45 | +fig.plot(x=1.5, y=1, style="j120/5/0.5", color="red3", pen="2p,black") |
| 46 | +# Rectangle |
| 47 | +fig.plot(x=3, y=1, style="r4/1.5", color="dodgerblue", pen="2p,black") |
| 48 | +# Rounded rectangle |
| 49 | +fig.plot(x=4.5, y=1, style="R1.25/4/0.5", color="seagreen", pen="2p,black") |
| 50 | +# Pie wedge |
| 51 | +fig.plot(x=5.5, y=1, style="w2.5/45/330", color="lightgray", pen="2p,black") |
33 | 52 |
|
34 | | -# ROTATED RECTANGLE |
35 | | -data = [[1.5, 1, 120, 5, 0.5]] |
36 | | -fig.plot(data=data, style="j", color="red3", pen="2p,black") |
| 53 | +fig.show() |
37 | 54 |
|
38 | | -# RECTANGLE |
39 | | -data = [[3, 1, 4, 1.5]] |
40 | | -fig.plot(data=data, style="r", color="dodgerblue", pen="2p,black") |
| 55 | +######################################################################################## |
| 56 | +# We can also plot symbols with varying parameters via defining those values in |
| 57 | +# a 2d list or numpy array (``[[parameters]]`` for a single symbol or |
| 58 | +# ``[[parameters_1],[parameters_2],[parameters_i]]`` for several ones) or using |
| 59 | +# an appropriately formatted input file and passing it to ``data``. |
| 60 | +# |
| 61 | +# The symbol parameters in the 2d list or numpy array are defined as: |
| 62 | +# |
| 63 | +# - **e**: ellipse, ``[[lon, lat, direction, major_axis, minor_axis]]`` |
| 64 | +# - **j**: rotated rectangle, ``[[lon, lat, direction, width, height]]`` |
| 65 | +# - **r**: rectangle, ``[[lon, lat, width, height]]`` |
| 66 | +# - **R**: rounded rectangle, ``[[lon, lat, width, height, radius]]`` |
| 67 | +# - **w**: pie wedge, ``[[lon, lat, radius, startdir, stopdir]]``, the last two |
| 68 | +# arguments are directions given in degrees counter-clockwise from horizontal |
41 | 69 |
|
42 | | -# ROUNDED RECTANGLE |
43 | | -data = [[4.5, 1, 1.25, 4, 0.5]] |
44 | | -fig.plot(data=data, style="R", color="seagreen", pen="2p,black") |
| 70 | +fig = pygmt.Figure() |
| 71 | +fig.basemap(region=[0, 6, 0, 4], projection="x3c", frame=["xa1f0.2", "ya0.5f0.1"]) |
45 | 72 |
|
46 | | -# PIE WEDGE |
47 | | -data = [[5.5, 1, 2.5, 45, 330]] |
| 73 | +# Ellipse |
| 74 | +data = [[0.5, 1, 45, 3, 1], [0.5, 3, 135, 2, 1]] |
| 75 | +fig.plot(data=data, style="e", color="orange", pen="2p,black") |
| 76 | +# Rotated rectangle |
| 77 | +data = [[1.5, 1, 120, 5, 0.5], [1.5, 3, 50, 3, 0.5]] |
| 78 | +fig.plot(data=data, style="j", color="red3", pen="2p,black") |
| 79 | +# Rectangle |
| 80 | +data = [[3, 1, 4, 1.5], [3, 3, 3, 1.5]] |
| 81 | +fig.plot(data=data, style="r", color="dodgerblue", pen="2p,black") |
| 82 | +# Rounded rectangle |
| 83 | +data = [[4.5, 1, 1.25, 4, 0.5], [4.5, 3, 1.25, 2.0, 0.2]] |
| 84 | +fig.plot(data=data, style="R", color="seagreen", pen="2p,black") |
| 85 | +# Pie wedge |
| 86 | +data = [[5.5, 1, 2.5, 45, 330], [5.5, 3, 1.5, 60, 300]] |
48 | 87 | fig.plot(data=data, style="w", color="lightgray", pen="2p,black") |
49 | 88 |
|
50 | 89 | fig.show() |
0 commit comments