Labeller ¶
Labeller(
base: Literal,
*,
multi_line: bool = True,
sep: str = ": ",
lookup: Mapping[str, str] | None = None,
function: Callable[[str], str] | None = None,
)
Bases: ggrust.plot.core.FeatureSpec
A facet strip labeller.
Build one with :data:label_value, :data:label_both, :data:label_context
or :func:as_labeller. Calling a labeller returns a copy with new options.
Parameters:
-
base((value, both, context), default:"value") –How variable names and values combine: the value alone,
name: value, orname: valueonly when a strip group has several variables. -
multi_line(bool, default:True) –Whether each variable gets its own strip.
Falsejoins them into one strip ("cyl, drv: 4, f"), wrapped at the firstlabwidth. -
sep(str, default:": ") –Separator between the variable name and the value.
-
lookup(Mapping[str, str], default:None) –Per-value labels (
as_labeller); values not in it keep their text. -
function(Callable[[str], str], default:None) –Per-value function (
as_labeller), called with each level's text (a number as its plain value,"1000", as ggplot2).
Raises:
-
TypeError–When
multi_lineis not a bool orsepis not a string.
Examples:
>>> from ggrust import *
>>> labeller = Labeller("both", sep=" = ")
>>> labeller.as_dict()["sep"]
' = '