`Axes` and its submobjects does not respect passed colors
Description of bug / unexpected behavior
I set the background is white, but the numbers with Black color nearby the axis don't display
Expected behavior
I should see the black number label when background is white
How to reproduce the issue
Code for reproducing the problem
from manim import *
#from scipy.stats import norm
#import os
config.media_width="10%"
config.background_color="WHITE"
class Test(Scene):
def construct(self):
axes = Axes( x_range=[-1,8],y_range=[-1,70],
#axis_config={"color": BLACK},
x_axis_config={"color": BLACK,
"include_numbers": True,
"decimal_number_config": {
"color": BLACK,
"num_decimal_places": 0
}
},
y_axis_config={"color": BLACK,
"include_ticks": False}
)
self.add(axes)
redcolor=ManimColor.from_rgb([255,0,0])
bluecolor=ManimColor.from_rgb([0,0,255])
Parabola_graph=axes.plot(lambda x: x**3, color=bluecolor)
line_graph=axes.plot(lambda x: 15*x+4, color=redcolor)
self.play(Create(Parabola_graph), Create(line_graph),run_time=5)
Additional media files
Images/GIFs
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
This is an issue with how coloring of Axes is handled during initialization of the object. The best solution (for now) is to take care of coloring in a second step, after creating the object:
from manim import *
config.background_color = WHITE
class Test(Scene):
def construct(self):
axes = Axes(x_range=[-1, 8], y_range=[-1, 70],
x_axis_config={
"include_numbers": True,
"decimal_number_config": {"num_decimal_places": 0}
},
y_axis_config={"include_ticks": False}
)
axes.set_color(BLACK)
self.add(axes)
redcolor = ManimColor.from_rgb([255,0,0])
bluecolor = ManimColor.from_rgb([0,0,255])
Parabola_graph = axes.plot(lambda x: x**3, color=bluecolor)
line_graph = axes.plot(lambda x: 15*x+4, color=redcolor)
self.play(Create(Parabola_graph), Create(line_graph), run_time=5)
+1
When animating the axis with e.g. self.play(Write(axes)), the numbers briefly show up
Is this issue resolved? I tried the same code as
Code for reproducing the problem
from manim import * #from scipy.stats import norm #import os config.media_width="10%" config.background_color="WHITE" class Test(Scene): def construct(self): axes = Axes( x_range=[-1,8],y_range=[-1,70], #axis_config={"color": BLACK}, x_axis_config={"color": BLACK, "include_numbers": True, "decimal_number_config": { "color": BLACK, "num_decimal_places": 0 } }, y_axis_config={"color": BLACK, "include_ticks": False} ) self.add(axes) redcolor=ManimColor.from_rgb([255,0,0]) bluecolor=ManimColor.from_rgb([0,0,255]) Parabola_graph=axes.plot(lambda x: x**3, color=bluecolor) line_graph=axes.plot(lambda x: 15*x+4, color=redcolor) self.play(Create(Parabola_graph), Create(line_graph),run_time=5)
And got this output
I have boiled down the issue to the DecimalNumber class used inside the Axes class.
We can see in the following code, when the color is BLACK, we get a white number.
I have made the background grey, so that we can see both the colors as and when they appear.
This unexpected behavior is only for the BLACK color. Any other color works just fine.
from manim import *
config.media_width = "10%"
config.background_color = "GREY"
config.quality = "low_quality"
class Test(Scene):
def construct(self):
deciBlack = DecimalNumber(5, color=BLACK)
deciGreen = DecimalNumber(5, color=GREEN)
deciGreen.next_to(deciBlack, direction=DOWN)
self.play(Write(deciBlack), Write(deciGreen))
self.wait(1)
Added a fix for this issue in this PR. @behackl
We might need to rethink about some of the underlying assumptions of the VMobject class initializing the color properties.
However for mitigating this specific issue I've opened this PR. It is a very small change (1 line) and safe change. Please review. #4291
I've explained the mitigation steps in detail inside the PR description.