Changed how configuration for labels on a NumberLine, and hence also on Axes, so that it takes in DecimalNumber configuration directly rather than as a separte dict.

This commit is contained in:
Grant Sanderson 2021-02-06 11:06:38 -08:00
parent 1a5a59f40e
commit 6f69902892
4 changed files with 13 additions and 16 deletions

View file

@ -475,7 +475,7 @@ OpeningManimExample
moving_c_grid = c_grid.copy() moving_c_grid = c_grid.copy()
moving_c_grid.prepare_for_nonlinear_transform() moving_c_grid.prepare_for_nonlinear_transform()
c_grid.set_stroke(BLUE_E, 1) c_grid.set_stroke(BLUE_E, 1)
c_grid.add_coordinate_labels(number_config={"font_size": 36}) c_grid.add_coordinate_labels(font_size=24)
complex_map_words = TexText(""" complex_map_words = TexText("""
Or thinking of the plane as $\\mathds{C}$,\\\\ Or thinking of the plane as $\\mathds{C}$,\\\\
this is the map $z \\rightarrow z^2$ this is the map $z \\rightarrow z^2$

View file

@ -45,7 +45,7 @@ class OpeningManimExample(Scene):
moving_c_grid = c_grid.copy() moving_c_grid = c_grid.copy()
moving_c_grid.prepare_for_nonlinear_transform() moving_c_grid.prepare_for_nonlinear_transform()
c_grid.set_stroke(BLUE_E, 1) c_grid.set_stroke(BLUE_E, 1)
c_grid.add_coordinate_labels(number_config={"font_size": 36}) c_grid.add_coordinate_labels(font_size=24)
complex_map_words = TexText(""" complex_map_words = TexText("""
Or thinking of the plane as $\\mathds{C}$,\\\\ Or thinking of the plane as $\\mathds{C}$,\\\\
this is the map $z \\rightarrow z^2$ this is the map $z \\rightarrow z^2$
@ -109,7 +109,6 @@ class InteractiveDevlopment(Scene):
always(circle.move_to, self.mouse_point) always(circle.move_to, self.mouse_point)
class AnimatingMethods(Scene): class AnimatingMethods(Scene):
def construct(self): def construct(self):
grid = Tex(r"\pi").get_grid(10, 10, height=4) grid = Tex(r"\pi").get_grid(10, 10, height=4)

View file

@ -297,11 +297,17 @@ class Axes(VGroup, CoordinateSystem):
def get_axes(self): def get_axes(self):
return self.axes return self.axes
def add_coordinate_labels(self, x_values=None, y_values=None): def add_coordinate_labels(self,
x_values=None,
y_values=None,
excluding=[0],
**kwargs):
axes = self.get_axes() axes = self.get_axes()
self.coordinate_labels = VGroup() self.coordinate_labels = VGroup()
for axis, values in zip(axes, [x_values, y_values]): for axis, values in zip(axes, [x_values, y_values]):
numbers = axis.add_numbers(values, excluding=[0]) numbers = axis.add_numbers(
values, excluding=excluding, **kwargs
)
self.coordinate_labels.add(numbers) self.coordinate_labels.add(numbers)
return self.coordinate_labels return self.coordinate_labels
@ -350,9 +356,6 @@ class NumberPlane(Axes):
"include_tip": False, "include_tip": False,
"line_to_number_buff": SMALL_BUFF, "line_to_number_buff": SMALL_BUFF,
"line_to_number_direction": DL, "line_to_number_direction": DL,
"decimal_number_config": {
"height": 0.2,
}
}, },
"y_axis_config": { "y_axis_config": {
"line_to_number_direction": DL, "line_to_number_direction": DL,
@ -477,10 +480,7 @@ class ComplexPlane(NumberPlane):
if abs(z.imag) > abs(z.real): if abs(z.imag) > abs(z.real):
axis = self.get_y_axis() axis = self.get_y_axis()
value = z.imag value = z.imag
kwargs = merge_dicts_recursively( kwargs["unit"] = "i"
kwargs,
{"number_config": {"unit": "i"}},
)
else: else:
axis = self.get_x_axis() axis = self.get_x_axis()
value = z.real value = z.real

View file

@ -127,11 +127,9 @@ class NumberLine(Line):
return self.get_length() / (self.x_max - self.x_min) return self.get_length() / (self.x_max - self.x_min)
def get_number_mobject(self, x, def get_number_mobject(self, x,
number_config=None,
direction=None, direction=None,
buff=None): buff=None,
if number_config is None: **number_config):
number_config = {}
number_config = merge_dicts_recursively( number_config = merge_dicts_recursively(
self.decimal_number_config, number_config self.decimal_number_config, number_config
) )