|
| 1 | +""" |
| 2 | +Directional map rose |
| 3 | +==================== |
| 4 | +
|
| 5 | +The :meth:`pygmt.Figure.directional_rose` method allows to add directional roses on |
| 6 | +maps. Using the method without any arguments will plot a rose at the bottom left corner, |
| 7 | +but this example will focus on customizing its position and appearance. |
| 8 | +
|
| 9 | +Colors of the map roses can be adjusted using :gmt-term:`MAP_DEFAULT_PEN` and |
| 10 | +:gmt-term:`MAP_TICK_PEN_PRIMARY` via :func:`pygmt.config`. Customizing label font and |
| 11 | +color can be done via :gmt-term:`FONT_TITLE`. |
| 12 | +""" |
| 13 | + |
| 14 | +# %% |
| 15 | +import pygmt |
| 16 | +from pygmt.params import Position |
| 17 | + |
| 18 | +fig = pygmt.Figure() |
| 19 | + |
| 20 | +y0 = 20 |
| 21 | +y1 = -5 |
| 22 | +width = "1.5c" |
| 23 | + |
| 24 | +fig.basemap(region=[-5, 80, -17, 32], projection="M10c", frame=True) |
| 25 | + |
| 26 | +# Plain rose of 1.5 cm width showing an arrow towards North, a cross indicating the |
| 27 | +# cardinal directions, and a label for the North direction |
| 28 | +fig.directional_rose( |
| 29 | + width=width, labels=True, position=Position((0, y0), cstype="mapcoords") |
| 30 | +) |
| 31 | + |
| 32 | +# Fancy, 1.5 cm wide rose of level 1 and labels indicating the different directions |
| 33 | +fig.directional_rose( |
| 34 | + width=width, |
| 35 | + labels=True, |
| 36 | + position=Position((20, y0), cstype="mapcoords"), |
| 37 | + fancy=True, |
| 38 | +) |
| 39 | + |
| 40 | +# Fancy, 1.5 cm wide rose of level 2 and labels indicating the different directions |
| 41 | +fig.directional_rose( |
| 42 | + width=width, |
| 43 | + labels=True, |
| 44 | + position=Position((45, y0), cstype="mapcoords"), |
| 45 | + fancy=2, |
| 46 | +) |
| 47 | + |
| 48 | +# Fancy, 1.5 cm wide rose of level 3 and labels indicating the different directions |
| 49 | +fig.directional_rose( |
| 50 | + width=width, |
| 51 | + labels=True, |
| 52 | + position=Position((70, y0), cstype="mapcoords"), |
| 53 | + fancy=3, |
| 54 | +) |
| 55 | + |
| 56 | +# Plain rose of 1.5 cm width showing an arrow towards North, a cross indicating the |
| 57 | +# cardinal directions, and a label for the North direction. Colors of the rose and |
| 58 | +# labels are defined via MAP_TICK_PEN_PRIMARY and FONT_TITLE, respectively |
| 59 | +with pygmt.config(MAP_TICK_PEN_PRIMARY="purple", FONT_TITLE="8p,darkmagenta"): |
| 60 | + fig.directional_rose( |
| 61 | + width=width, |
| 62 | + labels=True, |
| 63 | + position=Position((0, y1), cstype="mapcoords"), |
| 64 | + ) |
| 65 | + |
| 66 | +# Fancy, 1.5 cm wide rose of level 1 with only one label indicating the North direction. |
| 67 | +# Colors of the rose and labels are defined via MAP_DEFAULT_PEN, MAP_TICK_PEN_PRIMARY |
| 68 | +# and FONT_TITLE, respectively. |
| 69 | +with pygmt.config( |
| 70 | + MAP_DEFAULT_PEN="default,pink", |
| 71 | + MAP_TICK_PEN_PRIMARY="red3", |
| 72 | + FONT_TITLE="8p,Bookman-Light,red3", |
| 73 | +): |
| 74 | + fig.directional_rose( |
| 75 | + width=width, |
| 76 | + labels=["", "", "", "N"], |
| 77 | + position=Position((20, y1), cstype="mapcoords"), |
| 78 | + fancy=True, |
| 79 | + ) |
| 80 | + |
| 81 | +# Fancy, 1.5 cm wide rose of level 2 with two labels indicating the West and East |
| 82 | +# directions |
| 83 | +with pygmt.config( |
| 84 | + MAP_DEFAULT_PEN="default,lightorange", |
| 85 | + MAP_TICK_PEN_PRIMARY="darkorange", |
| 86 | + FONT_TITLE="8p,Bookman-Light,darkorange", |
| 87 | +): |
| 88 | + fig.directional_rose( |
| 89 | + width=width, |
| 90 | + labels=["W", "E", "", ""], |
| 91 | + position=Position((45, y1), cstype="mapcoords"), |
| 92 | + fancy=2, |
| 93 | + ) |
| 94 | + |
| 95 | +# Fancy, 1.5 cm wide rose of level 3 with two labels indicating the North and South |
| 96 | +# directions |
| 97 | +with pygmt.config( |
| 98 | + MAP_DEFAULT_PEN="default,Dodgerblue4", |
| 99 | + MAP_TICK_PEN_PRIMARY="Dodgerblue", |
| 100 | + FONT_TITLE="8p,AvantGarde-Demi,Dodgerblue4", |
| 101 | +): |
| 102 | + fig.directional_rose( |
| 103 | + width=width, |
| 104 | + labels=["", "", "South", "North"], |
| 105 | + position=Position((70, y1), cstype="mapcoords"), |
| 106 | + fancy=3, |
| 107 | + ) |
| 108 | + |
| 109 | +fig.show() |
0 commit comments