|
8 | 8 | from pygmt.alias import Alias, AliasSystem |
9 | 9 | from pygmt.clib import Session |
10 | 10 | from pygmt.helpers import build_arg_list, fmt_docstring, use_alias |
11 | | -from pygmt.params import Box |
| 11 | +from pygmt.params import Box, Position |
12 | 12 |
|
13 | 13 | __doctest_skip__ = ["colorbar"] |
14 | 14 |
|
|
17 | 17 | @use_alias(C="cmap", D="position", L="equalsize", Z="zfile") |
18 | 18 | def colorbar( # noqa: PLR0913 |
19 | 19 | self, |
| 20 | + position: Position | None = None, |
| 21 | + length: float | None = None, |
| 22 | + width: float | None = None, |
| 23 | + orientation: Literal["horizontal", "vertical"] = "vertical", |
| 24 | + reverse: bool = False, |
| 25 | + nan_rectangle=False, |
| 26 | + sidebar_triangles=None, |
| 27 | + move_annots=None, |
| 28 | + box: Box | bool = False, |
20 | 29 | truncate: Sequence[float] | None = None, |
21 | 30 | shading: float | Sequence[float] | bool = False, |
22 | 31 | log: bool = False, |
23 | 32 | scale: float | None = None, |
24 | 33 | projection: str | None = None, |
25 | | - box: Box | bool = False, |
26 | | - frame: str | Sequence[str] | bool = False, |
27 | 34 | region: Sequence[float | str] | str | None = None, |
| 35 | + frame: str | Sequence[str] | bool = False, |
28 | 36 | verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] |
29 | 37 | | bool = False, |
30 | 38 | panel: int | Sequence[int] | bool = False, |
31 | | - transparency: float | None = None, |
32 | 39 | perspective: float | Sequence[float] | str | bool = False, |
| 40 | + transparency: float | None = None, |
33 | 41 | **kwargs, |
34 | 42 | ): |
35 | 43 | r""" |
@@ -162,7 +170,22 @@ def colorbar( # noqa: PLR0913 |
162 | 170 | """ |
163 | 171 | self._activate_figure() |
164 | 172 |
|
| 173 | + _dimension = (length, width) if width is not None else length |
| 174 | + |
165 | 175 | aliasdict = AliasSystem( |
| 176 | + D=[ |
| 177 | + Alias(position, name="position"), |
| 178 | + Alias(_dimension, name="width/height", prefix="+w", sep="/", size=2), |
| 179 | + Alias( |
| 180 | + orientation, |
| 181 | + name="orientation", |
| 182 | + mapping={"horizontal": "+h", "vertical": "+v"}, |
| 183 | + ), |
| 184 | + Alias(reverse, name="reverse", prefix="+r"), |
| 185 | + Alias(nan_rectangle, name="nan_rectangle", prefix="+n"), |
| 186 | + Alias(sidebar_triangles, name="sidebar_triangles", prefix="+e"), |
| 187 | + Alias(move_annots, name="move_annots", prefix="+m"), |
| 188 | + ], |
166 | 189 | F=Alias(box, name="box"), |
167 | 190 | G=Alias(truncate, name="truncate", sep="/", size=2), |
168 | 191 | I=Alias(shading, name="shading", sep="/", size=2), |
|
0 commit comments