fix: align throughput bars by same-x positioning instead of arrange Left-edge

This commit is contained in:
ViperEkura 2026-05-06 22:11:18 +08:00
parent ce2a7c165a
commit f6ccefb34e
1 changed files with 8 additions and 11 deletions

View File

@ -288,9 +288,6 @@ class ContinuousBatching(Scene):
.align_to(s_rect, LEFT).align_to(s_rect, UP)
s_num = Text("1.0x", font_size=24, color=RED)
s_label.next_to(s_rect, LEFT, buff=0.4)
s_num.next_to(s_rect, RIGHT, buff=0.4)
# ---- Continuous Batching row ----
c_label = Text("Continuous Batching", font_size=24, color=GREEN)
c_rect = Rectangle(width=bar_max_w, height=bar_h, color=GREEN, stroke_width=1.5)
@ -299,15 +296,15 @@ class ContinuousBatching(Scene):
.align_to(c_rect, LEFT).align_to(c_rect, UP)
c_num = Text("3.4x", font_size=24, color=GREEN)
c_label.next_to(c_rect, LEFT, buff=0.4)
c_num.next_to(c_rect, RIGHT, buff=0.4)
# position rects vertically stacked, same x
s_rect.move_to(ORIGIN + UP * (row_gap / 2 + bar_h / 2))
c_rect.move_to(ORIGIN + DOWN * (row_gap / 2 + bar_h / 2))
# stack rows, centre vertically
chart = VGroup(
VGroup(s_label, s_rect, s_bar, s_num),
VGroup(c_label, c_rect, c_bar, c_num),
)
chart.arrange(DOWN, buff=row_gap, aligned_edge=LEFT).move_to(ORIGIN)
# labels left, nums right, bars follow rects
s_label.next_to(s_rect, LEFT, buff=0.4)
c_label.next_to(c_rect, LEFT, buff=0.4)
s_num.next_to(s_rect, RIGHT, buff=0.4)
c_num.next_to(c_rect, RIGHT, buff=0.4)
self.play(
Create(s_rect), Create(c_rect),