Skip to content

Commit c68e1a3

Browse files
committed
Fix remaining bumplot issues
Fixed three critical issues: 1. CURVES EXTENDING BEYOND DISPLAYED TOKENS: - Added clamping to max_vocab_display in rank assignment - Particles with tokens beyond max rank are now capped at the max visible rank - Prevents curves from going to non-existent rank 9 when only showing 8 ranks 2. COLORBAR POSITION: - Moved to x=0.88 (was 0.90, then 0.86) - Now has proper small gap from main figure 3. ALPHA TRANSPARENCY: - Reduced to 0.1 for clear visibility of overlapping paths - Using explicit line.set_alpha() for better rendering - Transparency now clearly visible in dense areas The bumplot now correctly shows all particles within the visible rank range, with proper transparency and layout spacing.
1 parent 592f76c commit c68e1a3

File tree

4 files changed

+10
-51
lines changed

4 files changed

+10
-51
lines changed

code/quantum_conversations/custom_bumplot.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def create_custom_bumplot(
2121
metadata: Dict,
2222
ax: plt.Axes,
2323
colormap: str = 'RdYlGn',
24-
alpha: float = 0.2, # Lower alpha for better transparency visibility
24+
alpha: float = 0.1, # Very low alpha to test transparency
2525
linewidth: float = 2.5,
2626
curve_force: float = 0.3
2727
) -> None:
@@ -100,9 +100,11 @@ def create_custom_bumplot(
100100
y_segment = np.concatenate([y_segment, y_overlap])
101101

102102
# Plot this segment with explicit alpha
103-
ax.plot(x_segment, y_segment, color=color, alpha=alpha,
104-
linewidth=linewidth, solid_capstyle='round',
105-
solid_joinstyle='round', zorder=100, rasterized=False) # Below labels
103+
# Force matplotlib to use alpha blending
104+
line, = ax.plot(x_segment, y_segment, color=color,
105+
linewidth=linewidth, solid_capstyle='round',
106+
solid_joinstyle='round', zorder=100)
107+
line.set_alpha(alpha) # Explicitly set alpha on line object
106108

107109
except Exception as e:
108110
# Fallback to linear segments

code/quantum_conversations/visualizer.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,9 @@ def _prepare_bumplot_data(
589589
token_id = particle.tokens[t]
590590
# Use the rank map to ensure consistency
591591
rank = position_ranks[t].get(token_id, max_vocab_display + 1)
592+
# Clamp rank to max_vocab_display to prevent out-of-range curves
593+
if rank > max_vocab_display:
594+
rank = max_vocab_display # Put overflow at the max visible rank
592595
trajectory.append(float(rank)) # Use float for smoother curves
593596
else:
594597
trajectory.append(np.nan)
@@ -830,7 +833,7 @@ def _add_dual_probability_legend_improved(
830833

831834
# Create new smaller axis for colorbar with small gap from main plot
832835
# Position at bottom 1/3, narrow, with appropriate spacing
833-
small_cbar_ax = fig.add_axes([0.90, 0.15, 0.008, 0.25]) # [left, bottom, width, height]
836+
small_cbar_ax = fig.add_axes([0.88, 0.15, 0.008, 0.25]) # [left, bottom, width, height]
834837

835838
# Create colorbar in the smaller axis
836839
cbar = ColorbarBase(

code/test_refinements.png

-1.34 MB
Binary file not shown.

code/test_refinements.py

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)