FadeIn#
[1]:
import matplotlib.pyplot as plt
import numpy as np
from manim import *
config.media_embed = True
# generate data
np.random.seed(19680801)
all_data = [np.random.normal(0, std, 100) for std in range(6, 10)]
Manim Community v0.17.2
[2]:
# make plot
fig, ax = plt.subplots(figsize=(4, 3))
ax.violinplot(all_data, showmeans=False, showmedians=True)
ax.set_title("Violin plot")
ax.set_xlim(0.5, 4.5)
# save figure as array
fig.canvas.draw()
buf1 = np.array(fig.canvas.buffer_rgba())
# TODO: Find out why this needs to be converted to an array here, and not in the other example
[3]:
# make plot
fig, ax = plt.subplots(figsize=(4, 3))
ax.boxplot(all_data)
ax.set_title("Box plot")
ax.set_xlim(0.5, 4.5)
# save figure as array
fig.canvas.draw()
buf2 = np.array(fig.canvas.buffer_rgba())
[4]:
class Example(Scene):
def construct(self):
self.camera.background_color = BLUE_A
img1 = ImageMobject(buf1).set(height=6.5)
img2 = ImageMobject(buf2).set(height=6.5)
self.add(img1)
self.wait(0.5)
self.play(FadeIn(img2))
self.wait()
self.play(FadeOut(img2))
%manim -v WARNING -qh --disable_caching --progress_bar None Example
[ ]: