Skip to content

Commit 5d1a771

Browse files
authored
Figure.ternary: Use the new alias system for parameters alabel/blabel/clabel (#4036)
1 parent 73a8124 commit 5d1a771

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

pygmt/src/ternary.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import pandas as pd
66
from packaging.version import Version
77
from pygmt._typing import PathLike, TableLike
8+
from pygmt.alias import Alias, AliasSystem
89
from pygmt.clib import Session, __gmt_version__
910
from pygmt.helpers import build_arg_list, fmt_docstring, kwargs_to_strings, use_alias
1011

@@ -14,7 +15,6 @@
1415
B="frame",
1516
C="cmap",
1617
G="fill",
17-
L="alabel/blabel/clabel-",
1818
JX="width",
1919
R="region",
2020
S="style",
@@ -47,6 +47,7 @@ def ternary(
4747
Full GMT docs at :gmt-docs:`ternary.html`.
4848
4949
{aliases}
50+
- L=alabel/blabel/clabel
5051
5152
Parameters
5253
----------
@@ -85,9 +86,12 @@ def ternary(
8586
self._activate_figure()
8687

8788
# -Lalabel/blabel/clabel. '-' means skipping the label.
88-
labels = (alabel, blabel, clabel)
89-
if any(v is not None for v in labels):
90-
kwargs["L"] = "/".join(str(v) if v is not None else "-" for v in labels)
89+
_labels = [v if v is not None else "-" for v in (alabel, blabel, clabel)]
90+
labels = _labels if any(v != "-" for v in _labels) else None
91+
92+
aliasdict = AliasSystem(
93+
L=Alias(labels, name="alabel/blabel/clabel", sep="/", size=3),
94+
).merge(kwargs)
9195

9296
# TODO(GMT>=6.5.0): Remove the patch for upstream bug fixed in GMT 6.5.0.
9397
# See https://github.com/GenericMappingTools/pygmt/pull/2138
@@ -98,5 +102,5 @@ def ternary(
98102
with lib.virtualfile_in(check_kind="vector", data=data) as vintbl:
99103
lib.call_module(
100104
module="ternary",
101-
args=build_arg_list(kwargs, infile=vintbl),
105+
args=build_arg_list(aliasdict, infile=vintbl),
102106
)

0 commit comments

Comments
 (0)