ManimCommunity / manim

A community-maintained Python framework for creating mathematical animations.
https://www.manim.community
MIT License
25.09k stars 1.75k forks source link

`Axes` and its submobjects does not respect passed colors #3633

Open Ironman1905 opened 7 months ago

Ironman1905 commented 7 months ago

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 ```py 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

behackl commented 6 months ago

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)
jherkenhoff commented 5 months ago

+1 When animating the axis with e.g. self.play(Write(axes)), the numbers briefly show up

mdhvg commented 1 week ago

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 image