From f6ccefb34eb0a1d5ae829f048b8fd5306d15e5e7 Mon Sep 17 00:00:00 2001 From: ViperEkura <3081035982@qq.com> Date: Wed, 6 May 2026 22:11:18 +0800 Subject: [PATCH] fix: align throughput bars by same-x positioning instead of arrange Left-edge --- continuous_batching.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/continuous_batching.py b/continuous_batching.py index 4abe76f..86267c3 100644 --- a/continuous_batching.py +++ b/continuous_batching.py @@ -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),