Skip to content

Figure.ternary: Use the new alias system for parameters alabel/blabel/clabel #4036

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 1, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions pygmt/src/ternary.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pandas as pd
from packaging.version import Version
from pygmt._typing import PathLike, TableLike
from pygmt.alias import Alias, AliasSystem
from pygmt.clib import Session, __gmt_version__
from pygmt.helpers import build_arg_list, fmt_docstring, kwargs_to_strings, use_alias

Expand All @@ -14,7 +15,6 @@
B="frame",
C="cmap",
G="fill",
L="alabel/blabel/clabel-",
JX="width",
R="region",
S="style",
Expand Down Expand Up @@ -47,6 +47,7 @@ def ternary(
Full GMT docs at :gmt-docs:`ternary.html`.

{aliases}
- L=alabel/blabel/clabel

Parameters
----------
Expand Down Expand Up @@ -85,9 +86,12 @@ def ternary(
self._activate_figure()

# -Lalabel/blabel/clabel. '-' means skipping the label.
labels = (alabel, blabel, clabel)
if any(v is not None for v in labels):
kwargs["L"] = "/".join(str(v) if v is not None else "-" for v in labels)
_labels = [v if v is not None else "-" for v in (alabel, blabel, clabel)]
labels = _labels if any(v != "-" for v in _labels) else None

aliasdict = AliasSystem(
L=Alias(labels, name="alabel/blabel/clabel", sep="/", size=3),
).merge(kwargs)

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