23
23
t = "transparency" ,
24
24
)
25
25
@kwargs_to_strings (R = "sequence" , c = "sequence_comma" , p = "sequence" )
26
- def ternary (self , data , alabel = None , blabel = None , clabel = None , ** kwargs ):
26
+ def ternary (
27
+ self ,
28
+ data ,
29
+ alabel : str | None = None ,
30
+ blabel : str | None = None ,
31
+ clabel : str | None = None ,
32
+ ** kwargs ,
33
+ ):
27
34
r"""
28
35
Plot ternary diagrams.
29
36
@@ -56,14 +63,14 @@ def ternary(self, data, alabel=None, blabel=None, clabel=None, **kwargs):
56
63
and **c**.
57
64
{cmap}
58
65
{fill}
59
- alabel : str
60
- Set the label for the *a* vertex where the component is 100%. The
61
- label is placed at a distance of three times the
62
- :gmt-term:`MAP_LABEL_OFFSET` setting from the corner.
63
- blabel : str
64
- Set the label for the *b* vertex where the component is 100% .
65
- clabel : str
66
- Set the label for the *c* vertex where the component is 100% .
66
+ alabel
67
+ Set the label for the *a* vertex where the component is 100%. The label is
68
+ placed at a distance of three times the :gmt-term:`MAP_LABEL_OFFSET` setting
69
+ from the corner.
70
+ blabel
71
+ Same as ``alabel`` but for the *b* vertex.
72
+ clabel
73
+ Same as ``alabel`` but for the *c* vertex.
67
74
style : str
68
75
*symbol*\[\ *size*].
69
76
Plot individual symbols in a ternary diagram.
@@ -75,11 +82,10 @@ def ternary(self, data, alabel=None, blabel=None, clabel=None, **kwargs):
75
82
"""
76
83
kwargs = self ._preprocess (** kwargs )
77
84
78
- if alabel or blabel or clabel :
79
- alabel = str (alabel ) if alabel is not None else "-"
80
- blabel = str (blabel ) if blabel is not None else "-"
81
- clabel = str (clabel ) if clabel is not None else "-"
82
- kwargs ["L" ] = f"{ alabel } /{ blabel } /{ clabel } "
85
+ # -Lalabel/blabel/clabel. '-' means skipping the label.
86
+ labels = (alabel , blabel , clabel )
87
+ if any (v is not None for v in labels ):
88
+ kwargs ["L" ] = "/" .join (str (v ) if v is not None else "-" for v in labels )
83
89
84
90
# Patch for GMT < 6.5.0.
85
91
# See https://github.com/GenericMappingTools/pygmt/pull/2138
0 commit comments