Skip to content

Commit 8078a84

Browse files
committed
Fix
1 parent 06a5975 commit 8078a84

File tree

1 file changed

+14
-69
lines changed

1 file changed

+14
-69
lines changed

pygmt/src/directional_rose.py

Lines changed: 14 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,16 @@
55
from collections.abc import Sequence
66
from typing import Literal
77

8-
from pygmt._typing import AnchorCode
98
from pygmt.alias import Alias, AliasSystem
109
from pygmt.clib import Session
1110
from pygmt.exceptions import GMTInvalidInput
1211
from pygmt.helpers import build_arg_list
13-
from pygmt.params import Box
12+
from pygmt.params import Box, Position
1413

1514

16-
def directional_rose( # noqa: PLR0913
15+
def directional_rose(
1716
self,
18-
position: Sequence[float | str] | AnchorCode | None = None,
19-
position_type: Literal[
20-
"mapcoords", "boxcoords", "plotcoords", "inside", "outside"
21-
] = "plotcoords",
22-
anchor: AnchorCode | None = None,
23-
anchor_offset: Sequence[float | str] | None = None,
17+
position: Position | None = None,
2418
width: float | str | None = None,
2519
label: Sequence[str] | bool = False,
2620
fancy: Literal[1, 2, 3] | bool = False,
@@ -30,50 +24,14 @@ def directional_rose( # noqa: PLR0913
3024
| bool = False,
3125
transparency: float | None = None,
3226
):
33-
r"""
27+
"""
3428
Add a directional rose on the map.
3529
36-
The directional rose is plotted at the location defined by the reference point
37-
(specified by the **position** and *position_type** parameters) and anchor point
38-
(specified by the **anchor** and **anchor_offset** parameters). Refer to
39-
:doc:`/techref/reference_anchor_points` for details about the positioning.
40-
4130
Parameters
4231
----------
43-
position/position_type
44-
Specify the reference point on the map for the directional rose. The reference
45-
point can be specified in five different ways, which is selected by the
46-
**position_type** parameter. The actual reference point is then given by the
47-
coordinates or code specified by the **position** parameter.
48-
49-
The **position_type** parameter can be one of the following:
50-
51-
- ``"mapcoords"``: **position** is given as (*longitude*, *latitude*) in map
52-
coordinates.
53-
- ``"boxcoords"``: **position** is given as (*nx*, *ny*) in normalized
54-
coordinates, i.e., fractional coordinates between 0 and 1 in both the x and y
55-
directions. For example, (0, 0) is the lower-left corner and (1, 1) is the
56-
upper-right corner of the plot bounding box.
57-
- ``"plotcoords"``: **position** is given as (x, y) in plot coordinates, i.e.,
58-
the distances in inches, centimeters, or points from the lower left plot
59-
origin.
60-
- ``"inside"`` or ``"outside"``: **position** is one of the nine
61-
:doc:`2-character justification codes </techref/justification_codes>`, meaning
62-
placing the reference point at specific locations, either inside or outside
63-
the plot bounding box.
64-
anchor
65-
Anchor point of the directional rose, specified by one of the
66-
:doc:`2-character justification codes </techref/justification_codes>`.
67-
The default value depends on the **position_type** parameter.
68-
69-
- ``position_type="inside"``: **anchor** defaults to the same as **position**.
70-
- ``position_type="outside"``: **anchor** defaults to the mirror opposite of
71-
**position**.
72-
- Otherwise, **anchor** defaults to ``"MC"`` (middle center).
73-
anchor_offset
74-
*offset* or (*offset_x*, *offset_y*).
75-
Offset the anchor point by *offset_x* and *offset_y*. If a single value *offset*
76-
is given, *offset_y* = *offset_x* = *offset*.
32+
position
33+
Specify the position of the directional rose on a map. See
34+
:class:`pygmt.params.Position` for details.
7735
width
7836
Width of the rose in plot coordinates (append **i** (inch), **cm**
7937
(centimeters), or **p** (points)), or append % for a size in percentage of map
@@ -96,16 +54,16 @@ def directional_rose( # noqa: PLR0913
9654
rectangular box is drawn using :gmt-term:`MAP_FRAME_PEN`. To customize the box
9755
appearance, pass a :class:`pygmt.params.Box` object to control style, fill, pen,
9856
and other box properties.
99-
{perspective}
100-
{verbose}
101-
{transparency}
57+
$perspective
58+
$verbose
59+
$transparency
10260
10361
Examples
10462
--------
10563
>>> import pygmt
10664
>>> fig = pygmt.Figure()
10765
>>> fig.basemap(region=[0, 80, -30, 30], projection="M10c", frame=True)
108-
>>> fig.directional_rose(position=(10, 10), position_type="mapcoords")
66+
>>> fig.directional_rose(position=Position((10, 10), cstype="mapcoords"))
10967
>>> fig.show()
11068
"""
11169
self._activate_figure()
@@ -117,27 +75,14 @@ def directional_rose( # noqa: PLR0913
11775
aliasdict = AliasSystem(
11876
F=Alias(box, name="box"),
11977
Td=[
120-
Alias(
121-
position_type,
122-
name="position_type",
123-
mapping={
124-
"mapcoords": "g",
125-
"boxcoords": "n",
126-
"plotcoords": "x",
127-
"inside": "j",
128-
"outside": "J",
129-
},
130-
),
131-
Alias(position, name="position", sep="/", size=2),
132-
Alias(anchor, name="anchor", prefix="+j"),
133-
Alias(anchor_offset, name="anchor_offset", prefix="+o", sep="/", size=2),
78+
Alias(position, name="position"),
79+
Alias(width, name="width", prefix="+w"),
13480
Alias(fancy, name="fancy", prefix="+f"), # +F is not supported yet.
13581
Alias(label, name="label", prefix="+l", sep=",", size=4),
136-
Alias(width, name="width", prefix="+w"),
13782
],
138-
p=Alias(perspective, name="perspective"),
13983
).add_common(
14084
V=verbose,
85+
p=perspective,
14186
t=transparency,
14287
)
14388

0 commit comments

Comments
 (0)