altair.condition#
- altair.condition(predicate, if_true, if_false, *, empty=Undefined, **kwargs)#
A conditional attribute or encoding.
- Parameters:
- predicate: Parameter, PredicateComposition, expr.Expression, dict, or string
the selection predicate or test predicate for the condition. if a string is passed, it will be treated as a test operand.
- if_true:
the spec or object to use if the selection predicate is true
- if_false:
the spec or object to use if the selection predicate is false
- empty
For selection parameters, the predicate of empty selections returns
Trueby default. Override this behavior, withempty=False.Note
When
predicateis aParameterthat is used more than once,alt.condition(..., empty=...)provides granular control for eachcondition().- **kwargs:
additional keyword args are added to the resulting dict
- Returns:
- spec: dict or VegaLiteSchema
the spec that describes the condition