|
| 1 | +""" |
| 2 | +Line fronts |
| 3 | +----------- |
| 4 | +
|
| 5 | +Using the :meth:`pygmt.Figure.plot` method you can draw a so-called |
| 6 | +*front* which allows to plot specific symbols distributed along a line |
| 7 | +or curve. Typical use cases are weather fronts, fault lines, |
| 8 | +subduction zones, and more. |
| 9 | +
|
| 10 | +A front can be drawn by passing **f**\[±]\ *gap*\[/*size*] to the ``style`` |
| 11 | +parameter where *gap* defines the distance gap between the symbols and |
| 12 | +*size* the symbol size. If *gap* is negative, it is interpreted to mean |
| 13 | +the number of symbols along the front instead. If *gap* has a leading + |
| 14 | +then we use the value exactly as given [Default will start and end each |
| 15 | +line with a symbol, hence the *gap* is adjusted to fit]. If *size* is |
| 16 | +missing it is set to 30% of the *gap*, except when *gap* is negative |
| 17 | +and *size* is thus required. Append **+l** or **+r** to plot symbols on |
| 18 | +the left or right side of the front [Default is centered]. Append |
| 19 | +**+**\ *type* to specify which symbol to plot: **b**\ ox, **c**\ ircle, |
| 20 | +**f**\ ault (default), **s**\ lip, or **t**\ riangle. Slip means left-lateral |
| 21 | +or right-lateral strike-slip arrows (centered is not an option). The **+s** |
| 22 | +modifier optionally accepts the angle used to draw the vector (default is |
| 23 | +20). Alternatively, use **+S** which draws arcuate arrow heads. Append |
| 24 | +**+o**\ *offset* to offset the first symbol from the beginning of the front |
| 25 | +by that amount (default is 0). The chosen symbol is drawn with the same pen |
| 26 | +as set for the line (i.e., via the ``pen`` parameter). To use an alternate |
| 27 | +pen, append **+p**\ *pen*. To skip the outline, just use **+p** with no |
| 28 | +argument. To make the main front line invisible, add **+i**. |
| 29 | +
|
| 30 | +""" |
| 31 | + |
| 32 | +import numpy as np |
| 33 | +import pygmt |
| 34 | + |
| 35 | +# Generate a two-point line for plotting |
| 36 | +x = np.array([1, 4]) |
| 37 | +y = np.array([20, 20]) |
| 38 | + |
| 39 | +fig = pygmt.Figure() |
| 40 | +fig.basemap(region=[0, 10, 0, 20], projection="X15c/15c", frame='+t"Line Fronts"') |
| 41 | + |
| 42 | +# Plot the line using different front styles |
| 43 | +for frontstyle in [ |
| 44 | + # line with "faults" front style, same as +f (default) |
| 45 | + "f1c/0.25c", |
| 46 | + # line with box front style |
| 47 | + "f1c/0.25c+b", |
| 48 | + # line with circle front style |
| 49 | + "f1c/0.25c+c", |
| 50 | + # line with triangle front style |
| 51 | + "f1c/0.3c+t", |
| 52 | + # line with left-lateral ("+l") slip ("+s") front style, angle is set to 45 and |
| 53 | + # offset to 2.25 cm |
| 54 | + "f5c/1c+l+s45+o2.25c", |
| 55 | + # line with "faults" front style, symbols are plotted on the left side of the front |
| 56 | + "f1c/0.4c+l", |
| 57 | + # line with box front style, symbols are plotted on the left side of the front |
| 58 | + "f1c/0.3c+l+b", |
| 59 | + # line with circle front style, symbols are plotted on the right side of the front |
| 60 | + "f1c/0.4c+r+c", |
| 61 | + # line with triangle front style, symbols are plotted on the left side of the front |
| 62 | + "f1c/0.3c+l+t", |
| 63 | + # line with triangle front style, symbols are plotted on the right side of the front |
| 64 | + # use other pen for the outline of the symbol |
| 65 | + "f1c/0.4c+r+t+p1.5p,dodgerblue", |
| 66 | + # line with triangle front style, symbols are plotted on the right side of the front |
| 67 | + # and offset is set to 0.3 cm, skip the outline |
| 68 | + "f0.5c/0.3c+r+t+o0.3c+p", |
| 69 | + # line with triangle front style, symbols are plotted on the right side of the front |
| 70 | + # and offset is set to 0.3 cm, skip the outline and make the main front line invisible |
| 71 | + "f0.5c/0.3c+r+t+o0.3c+p+i", |
| 72 | +]: |
| 73 | + y -= 1 # move the current line down |
| 74 | + fig.plot(x=x, y=y, pen="1.25p", style=frontstyle, color="red3") |
| 75 | + fig.text( |
| 76 | + x=x[-1], |
| 77 | + y=y[-1], |
| 78 | + text=frontstyle, |
| 79 | + font="Courier-Bold", |
| 80 | + justify="ML", |
| 81 | + offset="0.75c/0c", |
| 82 | + ) |
| 83 | + |
| 84 | +fig.show() |
0 commit comments