[英]In manim, how do you set the text of the axis labels different to the axis units?
[英]How do you set the size of the x and y axis labels in manim?
我的 class 中的 setup_axes 方法如下所示。 但我不知道如何設置 label 尺寸
def setup_axes(self):
GraphScene.setup_axes(self)
init_label_x = 1970
end_label_x = 2018
step_x = 2
init_label_y = 100
end_label_y = 600
step_y = 100
self.x_axis.add_numbers(
*range(init_label_x, end_label_x + step_x, step_x),
)
self.y_axis.add_numbers(*range(init_label_y, end_label_y + step_y, step_y))
self.play(ShowCreation(self.x_axis), ShowCreation(self.y_axis))
我想到了。
graph_scene.py
使用NumberLine
來制作它的軸。 NumberLine
有一個名為'number_scale_val'
的配置條目
為了能夠設置這個,go 到graph_scene.py
並在配置中,添加行
"x_label_font_size": 0.75,
然后在 setup_axes, x_axis 中,在第 78 行附近(我已經進行了編輯,因此可能會有所不同),添加此行
number_scale_val = self.x_label_font_size,
所以它看起來像這樣:
self.x_leftmost_tick = self.x_min
x_axis = NumberLine(x_min=self.x_min,
x_max=self.x_max,
unit_size=self.space_unit_to_x,
number_scale_val=self.x_label_font_size, #<== this line added
tick_frequency=self.x_tick_frequency
)
對 Y 軸執行相同操作,然后在 class 中,在配置中添加這些行(將 0.5 更改為您喜歡的任何值):
"x_label_font_size": 0.5,
"y_label_font_size": 0.5,
那么你對 go 很好 - 你可以在你的軸上設置字體的大小
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.