Fails to FadeOut a text in Manim

The methode FadeOut fails with the object effectifs_text, I tried to tinker with scale without success.
Any idea?
Thanks

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>from manim import *
import numpy as np
class NormalDistributionNumbers(Scene):
def construct(self):
# Étape 1: Générer une liste de 100 nombres suivant une loi normale N(175, 20), arrondis à l'unité
random_numbers = np.random.normal(175, 15, 100).round().astype(int)
# Étape 2: Afficher ces nombres
numbers_text = VGroup(*[Text(f"{num}") for num in random_numbers])
numbers_text.arrange_in_grid(rows=10, cols=10, buff=0.5)
self.play(Write(numbers_text.scale(0.5)))
self.wait(2)
# Étape 3: Trier les nombres dans l'ordre croissant
sorted_numbers = sorted(random_numbers)
sorted_numbers_text = VGroup(
*[Text(f"{num}") for num in sorted_numbers])
sorted_numbers_text.arrange_in_grid(rows=10, cols=10, buff=0.5)
self.play(Transform(numbers_text.scale(0.5),
sorted_numbers_text.scale(0.5)))
self.wait(2)
# Étape 4: Colorier les nombres inférieurs à 175 en rouge et ceux supérieurs ou égaux à 175 en bleu
# Étape 5: Partitionner la série en 8 classes de même amplitude entière et labelliser les valeurs avec 8 couleurs
min_val = min(sorted_numbers)
max_val = max(sorted_numbers)
amplitude = max_val - min_val
# Assure que class_width est un entier
class_width = (amplitude + 7) // 8
colors = [PURE_RED, ORANGE, YELLOW,
PURE_GREEN, PURE_BLUE, PURPLE, PINK, TEAL]
for num_text, num in zip(numbers_text, sorted_numbers):
# Assure que class_index est dans les limites
class_index = min((num - min_val) // class_width, 7)
num_text.set_color(colors[class_index])
self.wait(2)
# Étape 6: Fusionner les nombres de chaque classe et les remplacer par leur effectif
class_counts = [0] * 8
for num in sorted_numbers:
# Assure que class_index est dans les limites
class_index = min((num - min_val) // class_width, 7)
class_counts[class_index] += 1
effectifs_text = VGroup(
*[Text(f"{count}").set_color(colors[i]) for i, count in enumerate(class_counts)])
effectifs_text.arrange(RIGHT, buff=1)
self.play(Transform(numbers_text.scale(
0.5), effectifs_text.scale(0.5)))
self.wait(2)
self.play(FadeOut(effectifs_text.scale(0.0005)))
print(type(effectifs_text))
# Étape 7: Construire un tableau d'effectifs pour chacune des classes de même amplitude
table_data = [["Taille (cm)", "Effectif"]]
for i, count in enumerate(class_counts):
class_label = f"[{min_val + i *
class_width}, {min_val + (i + 1) * class_width} ["
table_data.append([class_label, str(count)])
table = Table(
table_data,
include_outer_lines=True
)
# Colorier les cellules du tableau
for i, row in enumerate(table_data[1:], start=1):
table.add_to_back(table.get_cell(
(i, 0), color=colors[(i-1) % len(colors)]))
table.add_to_back(table.get_cell(
(i, 1), color=colors[(i-1) % len(colors)]))
self.play(FadeIn(table.scale(0.5)))
self.wait(2)
self.play(table.animate.shift(3*LEFT))
# Pour exécuter la scène
if __name__ == "__main__":
from manim import config
config.media_width = "75%"
scene = NormalDistributionNumbers()
scene.render()
</code>
<code>from manim import * import numpy as np class NormalDistributionNumbers(Scene): def construct(self): # Étape 1: Générer une liste de 100 nombres suivant une loi normale N(175, 20), arrondis à l'unité random_numbers = np.random.normal(175, 15, 100).round().astype(int) # Étape 2: Afficher ces nombres numbers_text = VGroup(*[Text(f"{num}") for num in random_numbers]) numbers_text.arrange_in_grid(rows=10, cols=10, buff=0.5) self.play(Write(numbers_text.scale(0.5))) self.wait(2) # Étape 3: Trier les nombres dans l'ordre croissant sorted_numbers = sorted(random_numbers) sorted_numbers_text = VGroup( *[Text(f"{num}") for num in sorted_numbers]) sorted_numbers_text.arrange_in_grid(rows=10, cols=10, buff=0.5) self.play(Transform(numbers_text.scale(0.5), sorted_numbers_text.scale(0.5))) self.wait(2) # Étape 4: Colorier les nombres inférieurs à 175 en rouge et ceux supérieurs ou égaux à 175 en bleu # Étape 5: Partitionner la série en 8 classes de même amplitude entière et labelliser les valeurs avec 8 couleurs min_val = min(sorted_numbers) max_val = max(sorted_numbers) amplitude = max_val - min_val # Assure que class_width est un entier class_width = (amplitude + 7) // 8 colors = [PURE_RED, ORANGE, YELLOW, PURE_GREEN, PURE_BLUE, PURPLE, PINK, TEAL] for num_text, num in zip(numbers_text, sorted_numbers): # Assure que class_index est dans les limites class_index = min((num - min_val) // class_width, 7) num_text.set_color(colors[class_index]) self.wait(2) # Étape 6: Fusionner les nombres de chaque classe et les remplacer par leur effectif class_counts = [0] * 8 for num in sorted_numbers: # Assure que class_index est dans les limites class_index = min((num - min_val) // class_width, 7) class_counts[class_index] += 1 effectifs_text = VGroup( *[Text(f"{count}").set_color(colors[i]) for i, count in enumerate(class_counts)]) effectifs_text.arrange(RIGHT, buff=1) self.play(Transform(numbers_text.scale( 0.5), effectifs_text.scale(0.5))) self.wait(2) self.play(FadeOut(effectifs_text.scale(0.0005))) print(type(effectifs_text)) # Étape 7: Construire un tableau d'effectifs pour chacune des classes de même amplitude table_data = [["Taille (cm)", "Effectif"]] for i, count in enumerate(class_counts): class_label = f"[{min_val + i * class_width}, {min_val + (i + 1) * class_width} [" table_data.append([class_label, str(count)]) table = Table( table_data, include_outer_lines=True ) # Colorier les cellules du tableau for i, row in enumerate(table_data[1:], start=1): table.add_to_back(table.get_cell( (i, 0), color=colors[(i-1) % len(colors)])) table.add_to_back(table.get_cell( (i, 1), color=colors[(i-1) % len(colors)])) self.play(FadeIn(table.scale(0.5))) self.wait(2) self.play(table.animate.shift(3*LEFT)) # Pour exécuter la scène if __name__ == "__main__": from manim import config config.media_width = "75%" scene = NormalDistributionNumbers() scene.render() </code>
from manim import *
import numpy as np


class NormalDistributionNumbers(Scene):
    def construct(self):
        # Étape 1: Générer une liste de 100 nombres suivant une loi normale N(175, 20), arrondis à l'unité
        random_numbers = np.random.normal(175, 15, 100).round().astype(int)

        # Étape 2: Afficher ces nombres
        numbers_text = VGroup(*[Text(f"{num}") for num in random_numbers])
        numbers_text.arrange_in_grid(rows=10, cols=10, buff=0.5)
        self.play(Write(numbers_text.scale(0.5)))
        self.wait(2)

        # Étape 3: Trier les nombres dans l'ordre croissant
        sorted_numbers = sorted(random_numbers)
        sorted_numbers_text = VGroup(
            *[Text(f"{num}") for num in sorted_numbers])
        sorted_numbers_text.arrange_in_grid(rows=10, cols=10, buff=0.5)
        self.play(Transform(numbers_text.scale(0.5),
                  sorted_numbers_text.scale(0.5)))
        self.wait(2)

        # Étape 4: Colorier les nombres inférieurs à 175 en rouge et ceux supérieurs ou égaux à 175 en bleu

        # Étape 5: Partitionner la série en 8 classes de même amplitude entière et labelliser les valeurs avec 8 couleurs
        min_val = min(sorted_numbers)
        max_val = max(sorted_numbers)
        amplitude = max_val - min_val
        # Assure que class_width est un entier
        class_width = (amplitude + 7) // 8

        colors = [PURE_RED, ORANGE, YELLOW,
                  PURE_GREEN, PURE_BLUE, PURPLE, PINK, TEAL]

        for num_text, num in zip(numbers_text, sorted_numbers):
            # Assure que class_index est dans les limites
            class_index = min((num - min_val) // class_width, 7)
            num_text.set_color(colors[class_index])

        self.wait(2)

        # Étape 6: Fusionner les nombres de chaque classe et les remplacer par leur effectif
        class_counts = [0] * 8
        for num in sorted_numbers:
            # Assure que class_index est dans les limites
            class_index = min((num - min_val) // class_width, 7)
            class_counts[class_index] += 1

        effectifs_text = VGroup(
            *[Text(f"{count}").set_color(colors[i]) for i, count in enumerate(class_counts)])
        effectifs_text.arrange(RIGHT, buff=1)
        self.play(Transform(numbers_text.scale(
            0.5), effectifs_text.scale(0.5)))
        self.wait(2)
        self.play(FadeOut(effectifs_text.scale(0.0005)))
        print(type(effectifs_text))

        # Étape 7: Construire un tableau d'effectifs pour chacune des classes de même amplitude
        table_data = [["Taille (cm)", "Effectif"]]
        for i, count in enumerate(class_counts):
            class_label = f"[{min_val + i *
                              class_width}, {min_val + (i + 1) * class_width} ["
            table_data.append([class_label, str(count)])

        table = Table(
            table_data,
            include_outer_lines=True
        )

        # Colorier les cellules du tableau
        for i, row in enumerate(table_data[1:], start=1):
            table.add_to_back(table.get_cell(
                (i, 0), color=colors[(i-1) % len(colors)]))
            table.add_to_back(table.get_cell(
                (i, 1), color=colors[(i-1) % len(colors)]))

        self.play(FadeIn(table.scale(0.5)))
        self.wait(2)
        self.play(table.animate.shift(3*LEFT))


# Pour exécuter la scène
if __name__ == "__main__":
    from manim import config
    config.media_width = "75%"
    scene = NormalDistributionNumbers()
    scene.render()

Next time, please provide a minimal example. Here I have to guess the line you have issues with. Luckily, there is only one FadeOut call here. Replace

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>self.play(FadeOut(effectifs_text.scale(0.0005)))
</code>
<code>self.play(FadeOut(effectifs_text.scale(0.0005))) </code>
self.play(FadeOut(effectifs_text.scale(0.0005)))

with

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>self.play(FadeOut(numbers_text))
</code>
<code>self.play(FadeOut(numbers_text)) </code>
self.play(FadeOut(numbers_text))

The number_text object is still on the screen, using Transform in the line before does not change that.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật