| 
 | 1 | +"""  | 
 | 2 | +directional_rose - Add a map directional rose.  | 
 | 3 | +"""  | 
 | 4 | + | 
 | 5 | +from collections.abc import Sequence  | 
 | 6 | +from typing import Literal  | 
 | 7 | + | 
 | 8 | +from pygmt._typing import AnchorCode  | 
 | 9 | +from pygmt.alias import Alias, AliasSystem  | 
 | 10 | +from pygmt.clib import Session  | 
 | 11 | +from pygmt.helpers import build_arg_list  | 
 | 12 | + | 
 | 13 | + | 
 | 14 | +def directional_rose(  | 
 | 15 | +    self,  | 
 | 16 | +    position,  | 
 | 17 | +    position_type: Literal["user", "justify", "mirror", "normalize", "plot"]  | 
 | 18 | +    | None = None,  | 
 | 19 | +    width=None,  | 
 | 20 | +    fancy: Literal[1, 2, 3] | bool = False,  | 
 | 21 | +    justify: AnchorCode | None = None,  | 
 | 22 | +    offset: Sequence[float | str] | None = None,  | 
 | 23 | +    label: Sequence[str] | bool = False,  | 
 | 24 | +):  | 
 | 25 | +    """  | 
 | 26 | +    Add a directional rose to the map.  | 
 | 27 | +
  | 
 | 28 | +    Parameters  | 
 | 29 | +    ----------  | 
 | 30 | +    width  | 
 | 31 | +        Width of the rose in plot coordinates (append **i** (inch),  | 
 | 32 | +        **cm** (centimeters), or **p** (points)), or append % for a size in percentage  | 
 | 33 | +        of map width [default is 10%].  | 
 | 34 | +    label  | 
 | 35 | +        A sequence of four strings to label the cardinal points W,E,S,N. Use a empty  | 
 | 36 | +        string to skip a specific label. If set to ``True``, use the default labels  | 
 | 37 | +        ``["W", "E", "S", "N"]``.  | 
 | 38 | +
  | 
 | 39 | +    Examples  | 
 | 40 | +    --------  | 
 | 41 | +    >>> import pygmt  | 
 | 42 | +    >>> fig = pygmt.Figure()  | 
 | 43 | +    >>> fig.basemap(region=[0, 80, -30, 30], projection="M10c", frame=True)  | 
 | 44 | +    >>> fig.directional_rose(position=(10, 10), position_type="user")  | 
 | 45 | +    >>> fig.show()  | 
 | 46 | +    """  | 
 | 47 | +    self._activate_figure()  | 
 | 48 | + | 
 | 49 | +    aliasdict = AliasSystem(  | 
 | 50 | +        Td=[  | 
 | 51 | +            Alias(  | 
 | 52 | +                position_type,  | 
 | 53 | +                name="position_type",  | 
 | 54 | +                mapping={  | 
 | 55 | +                    "user": "g",  | 
 | 56 | +                    "justify": "j",  | 
 | 57 | +                    "mirror": "J",  | 
 | 58 | +                    "normalize": "n",  | 
 | 59 | +                    "plot": "x",  | 
 | 60 | +                },  | 
 | 61 | +            ),  | 
 | 62 | +            Alias(position, name="position", separator="/"),  | 
 | 63 | +            Alias(width, name="width", prefix="+w"),  | 
 | 64 | +            Alias(fancy, name="fancy", prefix="+f"),  | 
 | 65 | +            Alias(justify, name="justify", prefix="+j"),  | 
 | 66 | +            Alias(label, name="label", prefix="+l", separator=",", size=4),  | 
 | 67 | +            Alias(offset, name="offset", prefix="+o", separator="/", size=[1, 2]),  | 
 | 68 | +        ]  | 
 | 69 | +    )  | 
 | 70 | + | 
 | 71 | +    with Session() as lib:  | 
 | 72 | +        lib.call_module(module="basemap", args=build_arg_list(aliasdict))  | 
0 commit comments