本文整理汇总了Python中mobject.tex_mobject.TextMobject.shift_onto_screen方法的典型用法代码示例。如果您正苦于以下问题:Python TextMobject.shift_onto_screen方法的具体用法?Python TextMobject.shift_onto_screen怎么用?Python TextMobject.shift_onto_screen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mobject.tex_mobject.TextMobject
的用法示例。
在下文中一共展示了TextMobject.shift_onto_screen方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_axes
# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import shift_onto_screen [as 别名]
def setup_axes(self, animate = True):
x_num_range = float(self.x_max - self.x_min)
x_axis = NumberLine(
x_min = self.x_min,
x_max = self.x_max,
space_unit_to_num = self.x_axis_width/x_num_range,
tick_frequency = self.x_tick_frequency,
leftmost_tick = self.x_leftmost_tick or self.x_min,
numbers_with_elongated_ticks = self.x_labeled_nums,
color = self.axes_color
)
x_axis.shift(self.graph_origin - x_axis.number_to_point(0))
if self.x_labeled_nums:
x_axis.add_numbers(*self.x_labeled_nums)
x_label = TextMobject(self.x_axis_label)
x_label.next_to(x_axis, RIGHT+UP, buff = SMALL_BUFF)
x_label.shift_onto_screen()
x_axis.add(x_label)
self.x_axis_label_mob = x_label
y_num_range = float(self.y_max - self.y_min)
y_axis = NumberLine(
x_min = self.y_min,
x_max = self.y_max,
space_unit_to_num = self.y_axis_height/y_num_range,
tick_frequency = self.y_tick_frequency,
leftmost_tick = self.y_bottom_tick or self.y_min,
numbers_with_elongated_ticks = self.y_labeled_nums,
color = self.axes_color
)
y_axis.shift(self.graph_origin-y_axis.number_to_point(0))
y_axis.rotate(np.pi/2, about_point = y_axis.number_to_point(0))
if self.y_labeled_nums:
y_axis.add_numbers(*self.y_labeled_nums)
y_axis.numbers.shift(self.y_axis_numbers_nudge)
y_label = TextMobject(self.y_axis_label)
y_label.next_to(y_axis.get_top(), RIGHT, buff = 2*MED_BUFF)
y_label.shift_onto_screen()
y_axis.add(y_label)
self.y_axis_label_mob = y_label
if animate:
self.play(Write(VGroup(x_axis, y_axis)))
else:
selfe.add(x_axis, y_axis_label)
self.x_axis, self.y_axis = x_axis, y_axis
示例2: setup_axes
# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import shift_onto_screen [as 别名]
def setup_axes(self, animate = False):
x_num_range = float(self.x_max - self.x_min)
self.space_unit_to_x = self.x_axis_width/x_num_range
self.x_labeled_nums = self.x_labeled_nums or []
x_axis = NumberLine(
x_min = self.x_min,
x_max = self.x_max,
space_unit_to_num = self.space_unit_to_x,
tick_frequency = self.x_tick_frequency,
leftmost_tick = self.x_leftmost_tick or self.x_min,
numbers_with_elongated_ticks = self.x_labeled_nums,
color = self.axes_color
)
x_axis.shift(self.graph_origin - x_axis.number_to_point(0))
if len(self.x_labeled_nums) > 0:
if self.exclude_zero_label:
self.x_labeled_nums = filter(
lambda x : x != 0,
self.x_labeled_nums
)
x_axis.add_numbers(*self.x_labeled_nums)
x_label = TextMobject(self.x_axis_label)
x_label.next_to(
x_axis.get_tick_marks(), UP+RIGHT,
buff = SMALL_BUFF
)
x_label.shift_onto_screen()
x_axis.add(x_label)
self.x_axis_label_mob = x_label
y_num_range = float(self.y_max - self.y_min)
self.space_unit_to_y = self.y_axis_height/y_num_range
self.y_labeled_nums = self.y_labeled_nums or []
y_axis = NumberLine(
x_min = self.y_min,
x_max = self.y_max,
space_unit_to_num = self.space_unit_to_y,
tick_frequency = self.y_tick_frequency,
leftmost_tick = self.y_bottom_tick or self.y_min,
numbers_with_elongated_ticks = self.y_labeled_nums,
color = self.axes_color
)
y_axis.shift(self.graph_origin-y_axis.number_to_point(0))
y_axis.rotate(np.pi/2, about_point = y_axis.number_to_point(0))
if len(self.y_labeled_nums) > 0:
if self.exclude_zero_label:
self.y_labeled_nums = filter(
lambda y : y != 0,
self.y_labeled_nums
)
y_axis.add_numbers(*self.y_labeled_nums)
for mob in y_axis.numbers:
mob.next_to(mob.get_center(), LEFT, MED_SMALL_BUFF)
mob.shift(self.y_axis_numbers_nudge)
y_label = TextMobject(self.y_axis_label)
y_label.next_to(
y_axis.get_tick_marks(), UP+RIGHT,
buff = SMALL_BUFF
)
y_label.shift_onto_screen()
y_axis.add(y_label)
self.y_axis_label_mob = y_label
if animate:
self.play(Write(VGroup(x_axis, y_axis)))
else:
self.add(x_axis, y_axis)
self.x_axis, self.y_axis = self.axes = VGroup(x_axis, y_axis)
self.default_graph_colors = it.cycle(self.default_graph_colors)