Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added missing default_numbers_to_display() in NumberLine Class #4028

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions manim/mobject/graphing/number_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,18 @@ def get_number_mobject(
num_mob.shift(num_mob[0].width * LEFT / 2)
return num_mob

def default_numbers_to_display(self):
leftmost_tick = op.mul(
Fixed Show fixed Hide fixed
self.tick_frequency, np.ceil(self.x_min / self.tick_size)
)
numbers = np.arange(
np.floor(leftmost_tick),
np.ceil(self.x_max),
)
if self.exclude_zero_from_default_numbers:
numbers = numbers[numbers != 0]
return numbers

def get_number_mobjects(self, *numbers, **kwargs) -> VGroup:
if len(numbers) == 0:
numbers = self.default_numbers_to_display()
Expand Down