Skip to content
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

Figure.ternary: Add parameters alabel, blabel, and clabel #2139

Merged
merged 16 commits into from
Oct 5, 2022
23 changes: 22 additions & 1 deletion pygmt/src/ternary.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
t="transparency",
)
@kwargs_to_strings(R="sequence", c="sequence_comma", p="sequence")
def ternary(self, data, **kwargs):
def ternary(self, data, alabel=None, blabel=None, clabel=None, **kwargs):
r"""
Reads (*a*,\ *b*,\ *c*\ [,\ *z*]) records from *data* and plots symbols at
those locations on a ternary diagram. If a symbol is selected and no symbol
Expand Down Expand Up @@ -54,6 +54,14 @@ def ternary(self, data, **kwargs):
and **c**.
{cmap}
{fill}
alabel : str
Set the label for the *a* vertex where the component is 100%. The
label is placed at a distance of three times the
:gmt-term:`MAP_LABEL_OFFSET` setting from the corner.
blabel : str
Set the label for the *b* vertex where the component is 100%.
clabel : str
Set the label for the *c* vertex where the component is 100%.
style : str
*symbol*\[\ *size*].
Plot individual symbols in a ternary diagram.
Expand All @@ -66,8 +74,21 @@ def ternary(self, data, **kwargs):
{transparency}
"""
kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access

if alabel is None:
alabel = "-"

if blabel is None:
blabel = "-"

if clabel is None:
clabel = "-"

michaelgrund marked this conversation as resolved.
Show resolved Hide resolved
kwargs["L"] = "/".join([alabel, blabel, clabel])
michaelgrund marked this conversation as resolved.
Show resolved Hide resolved

with Session() as lib:
file_context = lib.virtualfile_from_data(check_kind="vector", data=data)

michaelgrund marked this conversation as resolved.
Show resolved Hide resolved
with file_context as infile:
lib.call_module(
module="ternary",
Expand Down