enter_fade ¶
enter_fade(alpha: float = 0) -> FeatureSpec
Fade marks in as they enter (gganimate enter_fade).
A mark that has no partner in the state before (matched by group, as the
transition moves marks) starts at alpha and moves to its own opacity
over the transition. Marks with an alpha get alpha; marks without
one get their color and fill at that opacity. Several enter effects added
with + apply one after the other (enter_fade() + enter_grow()).
Without any enter effect, new marks appear when their state is reached.
Works with transition_states() and transition_time().
Parameters:
-
alpha(float, default:0) –The opacity entering marks start from, between 0 and 1.
Returns:
-
FeatureSpec–The effect (kind
"animation"), added to a plot with+.
Raises:
-
SpecError–If
alphais not a number between 0 and 1.
Examples:
>>> from ggrust import *
>>> data = {"year": [2021, 2022, 2022], "fruit": ["apple", "apple", "pear"], "sold": [3, 4, 2]}
>>> plot = (
... ggplot(data, aes("fruit", "sold"))
... + geom_col()
... + transition_states("year")
... + enter_fade()
... )
>>> plot.as_dict()["animation"]["enter"]
[{'name': 'fade', 'alpha': 0.0}]
Bars that start half transparent:
>>> plot = (
... ggplot(data, aes("fruit", "sold"))
... + geom_col()
... + transition_states("year")
... + enter_fade(alpha=0.5)
... )
Bars that start half transparent