Resetting the opacity of NumberLine numbers doesn't animate smoothly
Description of bug / unexpected behavior
Create a number line with numbers. Animate a change in the opacity of the numbers, accessed with NumberLine.numbers. The opacity changes abruptly rather than smoothly.
Smooth opacity change can be obtained by putting the numbers in a VGroup, but then the axis disappears.
Expected behavior
The opacity should change smoothly without removing the axis.
How to reproduce the issue
Code for reproducing the problem
from manim import *
class numberline(Scene):
def construct(self):
abrupt_opacity = Tex("Opacity changes abruptly:").shift(UP)
number_line = NumberLine(include_numbers = True)
self.add(abrupt_opacity, number_line)
self.wait(1)
self.play(
number_line.numbers.animate.set_fill(opacity = .2)
)
self.wait(1)
self.remove(abrupt_opacity, number_line)
self.wait(1)
axis_disappers = Tex("Axis disappears:").shift(UP)
number_line = NumberLine(include_numbers = True)
self.add(axis_disappers, number_line)
self.wait(1)
self.play(
VGroup(*number_line.numbers).animate.set_fill(opacity = .2)
)
self.wait(1)
Additional media files
Images/GIFs
https://user-images.githubusercontent.com/4729700/213765636-60e75df1-f128-42eb-86f1-4461c3a253eb.mp4
Logs
Terminal output
PASTE HERE OR PROVIDE LINK TO https://pastebin.com/ OR SIMILAR
System specifications
System Details
- OS (with version, e.g., Windows 10 v2004 or macOS 10.15 (Catalina)):
- RAM:
- Python version (
python/py/python3 --version): - Installed modules (provide output from
pip list):
PASTE HERE
LaTeX details
- LaTeX distribution (e.g. TeX Live 2020):
- Installed LaTeX packages:
FFMPEG
Output of ffmpeg -version:
PASTE HERE
Additional comments
Use number_line.animate.... instead of number_line.numbers.animate..... Just for fun, the second approach is also fixed by using ###VGroup(*number_line).animate....
from manim import *
class numberline(Scene):
def construct(self):
abrupt_opacity = Tex("Opacity changes abruptly:").shift(UP)
number_line = NumberLine(include_numbers = True)
self.add(abrupt_opacity, number_line)
self.wait(1)
self.play(
number_line.animate.set_fill(opacity = .2)
)
self.wait(1)
self.remove(abrupt_opacity, number_line)
self.wait(1)
axis_disappers = Tex("Axis disappears:").shift(UP)
number_line = NumberLine(include_numbers = True)
self.add(axis_disappers, number_line)
self.wait(1)
self.play(
VGroup(*number_line).animate.set_fill(opacity = .2)
)
self.wait(1)
https://user-images.githubusercontent.com/44656681/213896707-8a65dd5e-051b-4b60-8cc9-6e1a22ff93ad.mp4
Thanks for the workaround. But number_line.numbers.animate.set_fill(opacity = .2) should work, right?
I tested it again and your suggestion didn't work. However, if what you suggested should work, I don't know... I am a simple guy trying to learn Manim. The experts might share their suggestions regarding that ☺️.
Yes, that's what I mean. The workaround is great, but I believe it is still a bug that number_line.numbers.animate.set_fill(opacity = .2) does not work as expected. Thanks!