This commit is contained in:
chigoma333
2026-07-21 16:27:29 +02:00
parent 4503f99135
commit c050194be4
2 changed files with 41 additions and 14 deletions
+18 -5
View File
@@ -16,8 +16,14 @@ def format_val(x, pos=None):
# ==========================================
# 1. EDIT YOUR DATA HERE
# ==========================================
labels = ['Tetris AI test CPU', 'tet_cpu_per_row', '4 tet_cpu_per_row']
values = [41700, 909000, 909000*4] # e.g., Speed, FPS, Transactions per second (Higher is better)
# Define primary labels and subtext descriptions
labels_main = ['Bitboard Tetris', 'TET-CPU']
subtexts = ['AMD R7-7735H', '50Mhz']
# Combine them with newline characters
labels = [f"{main}\n{sub}" for main, sub in zip(labels_main, subtexts)]
values = [41700, 909000] # e.g., Speed, FPS, Transactions per second (Higher is better)
# Define your unit here (add a space at the start so it looks clean)
unit_label = "Moves per Second [Moves/sec]"
@@ -41,7 +47,7 @@ bars = ax.barh(labels, values, color=[competitor_color, brand_color], height=0.4
# ==========================================
# 3. CONFIGURE AXES
# ==========================================
# X-Axis Tick Formatting (The requested change)
# X-Axis Tick Formatting
ax.xaxis.set_major_formatter(ticker.FuncFormatter(format_val))
for spine in ax.spines.values():
@@ -50,7 +56,12 @@ ax.spines['bottom'].set_visible(True)
ax.spines['bottom'].set_color('white')
ax.spines['bottom'].set_path_effects(black_outline)
ax.tick_params(axis='both', colors='white', labelsize=12)
# Set base size for x-axis ticks
ax.tick_params(axis='x', colors='white', labelsize=12)
# Set larger font size specifically for Y-axis labels (Option 1)
ax.tick_params(axis='y', colors='white', labelsize=18)
for label in ax.get_xticklabels() + ax.get_yticklabels():
label.set_path_effects(black_outline)
@@ -83,7 +94,9 @@ multiplier_txt = ax.text(x_line + (max_val * 0.03), (y0+y1)/2, f'{multiplier:.1f
ha='left', va='center', color=brand_color, fontsize=22, fontweight='heavy')
multiplier_txt.set_path_effects(black_outline)
ax.set_xlim(0, max_val * 1.45)
# Set x-axis limit to end around 1.1M
ax.set_xlim(0, 1_100_000)
plt.tight_layout()
plt.subplots_adjust(bottom=0.2)
+23 -9
View File
@@ -16,8 +16,13 @@ def format_val(x, pos=None):
# ==========================================
# 1. EDIT YOUR DATA HERE
# ==========================================
labels = ['Tetris AI test CPU', 'tet_cpu_per_row', '4 tet_cpu_per_row']
values = [41700, 909000, 909000*4] # e.g., Speed, FPS, Transactions per second (Higher is better)
labels_main = ['Bitboard Tetris', 'TET-CPU', '4 TET-CPU']
subtexts = ['AMD R7-7735H', '50Mhz', '50Mhz']
# Combine main titles and subtexts with newline characters
labels = [f"{main}\n{sub}" for main, sub in zip(labels_main, subtexts)]
values = [41700, 909000, 909000 * 4] # e.g., Speed, FPS, Transactions per second (Higher is better)
# Define your unit here (add a space at the start so it looks clean)
unit_label = "Moves per Second [Moves/sec]"
@@ -27,7 +32,7 @@ brand_color = '#00E5FF'
competitor_color = '#888888'
max_val = max(values)
# Bracket will compare the first and last (or you can change these indices)
# Bracket will compare the first and last
start_val, end_val = values[0], values[-1]
multiplier = end_val / start_val
@@ -36,7 +41,7 @@ black_outline = [path_effects.withStroke(linewidth=3, foreground='black')]
# ==========================================
# 2. SETUP & DYNAMIC PLOTTING
# ==========================================
fig, ax = plt.subplots(figsize=(10, 6)) # Increased height for more labels
fig, ax = plt.subplots(figsize=(10, 6)) # Height for more labels
fig.patch.set_alpha(0.0)
ax.patch.set_alpha(0.0)
@@ -46,12 +51,18 @@ bars = ax.barh(labels, values, color=colors, height=0.5, zorder=3)
# Configure Axis
ax.xaxis.set_major_formatter(ticker.FuncFormatter(format_val))
for spine in ax.spines.values(): spine.set_visible(False)
for spine in ax.spines.values():
spine.set_visible(False)
ax.spines['bottom'].set_visible(True)
ax.spines['bottom'].set_color('white')
ax.spines['bottom'].set_path_effects(black_outline)
ax.tick_params(axis='both', colors='white', labelsize=12)
# Set base size for x-axis ticks
ax.tick_params(axis='x', colors='white', labelsize=12)
# Set larger font size specifically for Y-axis labels
ax.tick_params(axis='y', colors='white', labelsize=18)
for label in ax.get_xticklabels() + ax.get_yticklabels():
label.set_path_effects(black_outline)
@@ -73,19 +84,22 @@ for bar, val in zip(bars, values):
# 3. DYNAMIC BRACKET (First vs Last)
# ==========================================
y_start, y_end = bars[0].get_y() + bars[0].get_height()/2, bars[-1].get_y() + bars[-1].get_height()/2
x_line, x_tick = max_val * 1.10, max_val * 1.07 # Shifted further right to accommodate N items
x_line, x_tick = max_val * 1.05, max_val * 1.02
l1, = ax.plot([x_tick, x_line], [y_end, y_end], color=brand_color, lw=2)
l2, = ax.plot([x_tick, x_line], [y_start, y_start], color=brand_color, lw=2)
l3, = ax.plot([x_line, x_line], [y_start, y_end], color=brand_color, lw=2)
for l in [l1, l2, l3]: l.set_path_effects(black_outline)
for l in [l1, l2, l3]:
l.set_path_effects(black_outline)
mult_txt = ax.text(x_line + (max_val * 0.03), (y_start+y_end)/2,
f'{multiplier:.1f}x\nFASTER',
ha='left', va='center', color=brand_color, fontsize=18, fontweight='heavy')
mult_txt.set_path_effects(black_outline)
ax.set_xlim(0, max_val * 1.5)
# Set x-axis limit so the axis line ends cleanly near ~4.4M with bracket room
ax.set_xlim(0, max_val * 1.25)
plt.tight_layout()
plt.subplots_adjust(bottom=0.2)
plt.savefig('dynamic_comparison.png', dpi=300, transparent=True)