|
| 1 | +""" |
| 2 | +Magnetic rose |
| 3 | +============= |
| 4 | +
|
| 5 | +The method :meth:`pygmt.Figure.magnetic_rose` can be used to add a magnetic rose to a |
| 6 | +map. This example shows how such a magnetic rose can be customized. |
| 7 | +""" |
| 8 | + |
| 9 | +# %% |
| 10 | +import pygmt |
| 11 | + |
| 12 | +fig = pygmt.Figure() |
| 13 | +fig.basemap(region=[-8, 8, -7, 7], projection="M10c", frame=True) |
| 14 | + |
| 15 | +# Add a magnetic rose |
| 16 | +# By default, it's placed in the lower left corner |
| 17 | +fig.magnetic_rose() |
| 18 | + |
| 19 | +# Add a magnetic rose with several adjustments |
| 20 | +with pygmt.config( |
| 21 | + # Pen used for the ticks on the outer circle and the outline of the North star |
| 22 | + MAP_TICK_PEN_SECONDARY="orange", |
| 23 | + # Pen used for the ticks related to the inner circle |
| 24 | + MAP_TICK_PEN_PRIMARY="cyan", |
| 25 | + # Pen used for the stem of the declination arrow and the fill of the North star |
| 26 | + MAP_DEFAULT_PEN="brown", |
| 27 | + # Font used for the labels for the geographic directions |
| 28 | + FONT_TITLE="purple", |
| 29 | +): |
| 30 | + fig.magnetic_rose( |
| 31 | + position="MC", # placed at MiddleCenter |
| 32 | + width=4.5, # width of the rose |
| 33 | + # If a declination value is given, an arrow showing the declination is plotted |
| 34 | + # instead of the simple North arrow |
| 35 | + declination=14.3, |
| 36 | + # Adjust the label added to the declination arrow |
| 37 | + declination_label="14.3 N°E", |
| 38 | + # Add labels for the geographic directions. Use a * to get a North star and |
| 39 | + # "" to skip a label |
| 40 | + labels=["W", "E", "South", "*"], |
| 41 | + # Draw an outer circle with the provided pen |
| 42 | + outer_pen="1p,red", |
| 43 | + # Draw an inner circle with the provided pen |
| 44 | + inner_pen="1p,blue", |
| 45 | + ) |
| 46 | + |
| 47 | +fig.show() |
0 commit comments