Skip to content

Commit a46dc2c

Browse files
committed
Add Figure.directional_rose to plot a directional rose on map
1 parent 170f82e commit a46dc2c

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed

pygmt/figure.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@ def _repr_html_(self) -> str:
435435
coast,
436436
colorbar,
437437
contour,
438+
directional_rose,
438439
grdcontour,
439440
grdimage,
440441
grdview,

pygmt/src/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from pygmt.src.config import config
1111
from pygmt.src.contour import contour
1212
from pygmt.src.dimfilter import dimfilter
13+
from pygmt.src.directional_rose import directional_rose
1314
from pygmt.src.filter1d import filter1d
1415
from pygmt.src.grd2cpt import grd2cpt
1516
from pygmt.src.grd2xyz import grd2xyz

pygmt/src/directional_rose.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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+
TODO
31+
32+
Examples
33+
--------
34+
>>> import pygmt
35+
>>> fig = pygmt.Figure()
36+
>>> fig.basemap(region=[0, 80, -30, 30], projection="M10c", frame=True)
37+
>>> fig.directional_rose(position=(10, 10), position_type="user")
38+
>>> fig.show()
39+
"""
40+
self._activate_figure()
41+
42+
aliasdict = AliasSystem(
43+
Td=[
44+
Alias(
45+
position_type,
46+
name="position_type",
47+
mapping={
48+
"user": "g",
49+
"justify": "j",
50+
"mirror": "J",
51+
"normalize": "n",
52+
"plot": "x",
53+
},
54+
),
55+
Alias(position, name="position", separator="/"),
56+
Alias(width, name="width", prefix="+w"),
57+
Alias(fancy, name="fancy", prefix="+f"),
58+
Alias(justify, name="justify", prefix="+j"),
59+
Alias(label, name="label", prefix="+l", separator=",", size=4),
60+
Alias(offset, name="offset", prefix="+o", separator="/", size=[1, 2]),
61+
]
62+
)
63+
64+
with Session() as lib:
65+
lib.call_module(module="basemap", args=build_arg_list(aliasdict))

0 commit comments

Comments
 (0)