plotly writes visible into every trace of every animation frame, so a
trace hidden with a click on the legend comes back on the next frame. This
removes visible from the frames, so the click lasts while the animation
plays. plotly also hides a trace, with visible = FALSE, in a frame where it
has no data, as a copy of its previous frame; that copy is emptied instead,
so nothing is drawn there.
Examples
keep_legend_clicks(plot_pyramid(mfi_population, country = "Greece", font_style = font_style))