Skip to content

Commit e9e0c7f

Browse files
committed
per channel plots
1 parent 4bbb5c8 commit e9e0c7f

File tree

1 file changed

+55
-68
lines changed

1 file changed

+55
-68
lines changed

analyze_color_by_style_range.py

Lines changed: 55 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -289,93 +289,80 @@ def plot_comparison_by_style_range(all_results: dict, output_dir: str):
289289
plt.savefig(output_dir / 'color_analysis_by_style_range_overview.png', dpi=150, bbox_inches='tight')
290290
plt.close()
291291

292-
# 2. RGB Channel Analysis - as % change
293-
fig, axes = plt.subplots(1, 2, figsize=(16, 6))
294-
295-
# Mean plot (as % change)
296-
ax = axes[0]
297-
for style_range in sorted(all_results.keys()):
298-
results = all_results[style_range]
299-
label = get_style_range_label(style_range)
300-
301-
# Compute average % change across R, G, B channels
302-
rgb_pct_changes = []
303-
for channel in ['R', 'G', 'B']:
292+
# 2. RGB Channel Analysis - individual channels as % change
293+
fig, axes = plt.subplots(2, 3, figsize=(18, 10))
294+
295+
rgb_channels = ['R', 'G', 'B']
296+
channel_colors = {'R': '#E63946', 'G': '#06D6A0', 'B': '#118AB2'}
297+
298+
# Row 1: Mean plots for each channel
299+
for col_idx, channel in enumerate(rgb_channels):
300+
ax = axes[0, col_idx]
301+
for style_range in sorted(all_results.keys()):
302+
results = all_results[style_range]
303+
label = get_style_range_label(style_range)
304304
vals = np.array(results[f'rgb_{channel}_mean'])
305305
ref_val = vals[ref_idx]
306306
pct_change = (vals / ref_val - 1) * 100
307-
rgb_pct_changes.append(pct_change)
308-
309-
# Average across channels
310-
avg_pct_change = np.mean(rgb_pct_changes, axis=0)
311-
ax.plot(results['alphas'], avg_pct_change,
312-
marker='o', linewidth=2, label=label, color=style_colors[style_range])
313-
314-
ax.set_xlabel('Alpha', fontsize=12)
315-
ax.set_ylabel('RGB Channel Mean Change (%)', fontsize=12)
316-
ax.set_title('RGB Channel Means vs Alpha (avg across R,G,B)', fontsize=14, fontweight='bold')
317-
ax.legend()
318-
ax.grid(True, alpha=0.3)
319-
ax.axhline(y=0, color='black', linestyle='-', alpha=0.3, linewidth=1)
320-
321-
# Std plot (as % change)
322-
ax = axes[1]
323-
for style_range in sorted(all_results.keys()):
324-
results = all_results[style_range]
325-
label = get_style_range_label(style_range)
326-
327-
# Compute average % change across R, G, B channels
328-
rgb_pct_changes = []
329-
for channel in ['R', 'G', 'B']:
307+
ax.plot(results['alphas'], pct_change,
308+
marker='o', linewidth=2, label=label, color=style_colors[style_range])
309+
310+
ax.set_xlabel('Alpha', fontsize=11)
311+
ax.set_ylabel(f'{channel} Channel Mean Change (%)', fontsize=11)
312+
ax.set_title(f'{channel} Channel Mean vs Alpha', fontsize=12, fontweight='bold', color=channel_colors[channel])
313+
ax.legend(fontsize=9)
314+
ax.grid(True, alpha=0.3)
315+
ax.axhline(y=0, color='black', linestyle='-', alpha=0.3, linewidth=1)
316+
317+
# Row 2: Std dev plots for each channel
318+
for col_idx, channel in enumerate(rgb_channels):
319+
ax = axes[1, col_idx]
320+
for style_range in sorted(all_results.keys()):
321+
results = all_results[style_range]
322+
label = get_style_range_label(style_range)
330323
vals = np.array(results[f'rgb_{channel}_std'])
331324
ref_val = vals[ref_idx]
332325
pct_change = (vals / ref_val - 1) * 100
333-
rgb_pct_changes.append(pct_change)
326+
ax.plot(results['alphas'], pct_change,
327+
marker='s', linewidth=2, label=label, color=style_colors[style_range])
334328

335-
# Average across channels
336-
avg_pct_change = np.mean(rgb_pct_changes, axis=0)
337-
ax.plot(results['alphas'], avg_pct_change,
338-
marker='s', linewidth=2, label=label, color=style_colors[style_range])
339-
340-
ax.set_xlabel('Alpha', fontsize=12)
341-
ax.set_ylabel('RGB Channel Std Dev Change (%)', fontsize=12)
342-
ax.set_title('RGB Channel Variation vs Alpha (avg across R,G,B)', fontsize=14, fontweight='bold')
343-
ax.legend()
344-
ax.grid(True, alpha=0.3)
345-
ax.axhline(y=0, color='black', linestyle='-', alpha=0.3, linewidth=1)
329+
ax.set_xlabel('Alpha', fontsize=11)
330+
ax.set_ylabel(f'{channel} Channel Std Dev Change (%)', fontsize=11)
331+
ax.set_title(f'{channel} Channel Variation vs Alpha', fontsize=12, fontweight='bold', color=channel_colors[channel])
332+
ax.legend(fontsize=9)
333+
ax.grid(True, alpha=0.3)
334+
ax.axhline(y=0, color='black', linestyle='-', alpha=0.3, linewidth=1)
346335

347336
plt.suptitle('RGB Channel Statistics by Style Range (% Change)',
348337
fontsize=16, y=0.995, fontweight='bold')
349338
plt.tight_layout()
350339
plt.savefig(output_dir / 'rgb_analysis_by_style_range.png', dpi=150, bbox_inches='tight')
351340
plt.close()
352341

353-
# 3. LAB channel analysis - as % change
354-
fig, ax = plt.subplots(1, 1, figsize=(12, 6))
342+
# 3. LAB channel analysis - individual channels as % change
343+
fig, axes = plt.subplots(1, 3, figsize=(18, 5))
355344

356-
for style_range in sorted(all_results.keys()):
357-
results = all_results[style_range]
358-
label = get_style_range_label(style_range)
345+
lab_channels = ['L', 'A', 'B']
346+
lab_names = ['Lightness (L)', 'Green-Red (a*)', 'Blue-Yellow (b*)']
347+
lab_colors = {'L': '#FFB703', 'A': '#06D6A0', 'B': '#118AB2'}
359348

360-
# Compute average % change across L, A, B channels
361-
lab_pct_changes = []
362-
for channel in ['L', 'A', 'B']:
349+
for col_idx, (channel, name) in enumerate(zip(lab_channels, lab_names)):
350+
ax = axes[col_idx]
351+
for style_range in sorted(all_results.keys()):
352+
results = all_results[style_range]
353+
label = get_style_range_label(style_range)
363354
vals = np.array(results[f'lab_{channel}_mean'])
364355
ref_val = vals[ref_idx]
365356
pct_change = (vals / ref_val - 1) * 100
366-
lab_pct_changes.append(pct_change)
367-
368-
# Average across channels
369-
avg_pct_change = np.mean(lab_pct_changes, axis=0)
370-
ax.plot(results['alphas'], avg_pct_change,
371-
marker='o', linewidth=2, label=label, color=style_colors[style_range])
372-
373-
ax.set_xlabel('Alpha', fontsize=12)
374-
ax.set_ylabel('LAB Channel Mean Change (%)', fontsize=12)
375-
ax.set_title('LAB Color Space vs Alpha (avg across L,a*,b*)', fontsize=14, fontweight='bold')
376-
ax.legend()
377-
ax.grid(True, alpha=0.3)
378-
ax.axhline(y=0, color='black', linestyle='-', alpha=0.3, linewidth=1)
357+
ax.plot(results['alphas'], pct_change,
358+
marker='o', linewidth=2, label=label, color=style_colors[style_range])
359+
360+
ax.set_xlabel('Alpha', fontsize=11)
361+
ax.set_ylabel(f'{name} Change (%)', fontsize=11)
362+
ax.set_title(f'{name} vs Alpha', fontsize=12, fontweight='bold', color=lab_colors[channel])
363+
ax.legend(fontsize=9)
364+
ax.grid(True, alpha=0.3)
365+
ax.axhline(y=0, color='black', linestyle='-', alpha=0.3, linewidth=1)
379366

380367
plt.suptitle('LAB Color Space by Style Range (% Change)',
381368
fontsize=16, y=0.995, fontweight='bold')

0 commit comments

Comments
 (0)