Search code examples
manim

How can I change the tip_width and tip_height of NumberLine? (manim v0.15.2)


(Hi. This is my very first question on stack overflow so please let me know if the question is unclear.)

I am trying to make the arrowhead of a NumberLine mobject smaller than its default (which is tip_width = 0.25, tip_height = 0.25). However the tip customization doesn't seem to be working. Here is the code and the result:

from manim import *

class NumberLineComparison(Scene):
  def construct(self):

    l0 = NumberLine(
      x_range=[-3,3],
      include_tip=True
    )

    l1 = NumberLine(
      x_range=[-3,3],
      include_tip=True,
      tip_width=0.1
    ).next_to(l0,DOWN)
    
    l2 = NumberLine(
      x_range=[-3,3],
      include_tip=True,
      tip_height=0.1
    ).next_to(l1,DOWN)

    self.add(l0,l1,l2)

Resulting Image

The changes in tip_width and tip_height attributes don't seem to be active...

Is this a bug or are there any problems with the syntax?


Solution

  • You need to define the attributes in the axis_config parameter. Here's a minimal working example:

    class NumberPlaneTips(Scene):    
    def construct(self):        
        grid = NumberPlane(
            x_range=[-2,5],
            y_range=[-2,5],
            axis_config={
                "include_numbers": True,
                "tip_width": 0.15, # adjust this
                "tip_height": 0.15, # and this
                "include_ticks": True,
                "tick_size": 0.05,
                "include_numbers": True,
                "include_tip": True, # Add a tip to x-axis and y-axis
            },
            
        )
    
        self.add(grid)
    

    You can also manipulate the x-axis and y-axis sub-Mobject individually, as follows ...

    class NumberPlaneTips(Scene):    
    def construct(self):        
        grid = NumberPlane(
            x_range=[-2,5],
            y_range=[-2,5],
            x_axis_config={
                # do stuff for x-axis
            },
            y_axis_config={
                # do stuff for y-axis
            },            
        )
    
        self.add(grid)