Skip to content

Commit ab8af8d

Browse files
committed
Increase font sizes and fix arrow overlaps in Binomial diagram
- Increase all font sizes (11-16 range) for better readability on mobile - Enlarge figure size from 10x6 to 12x7 - Reposition all arrows to completely avoid overlaps: * 'Count sequences' arrow from far left * 'Each sequence' arrow from upper right to FSS box edge * 'Multiply!' arrow from lower right clear of formula Much improved visibility and clarity.
1 parent b7d7d20 commit ab8af8d

1 file changed

Lines changed: 21 additions & 21 deletions

File tree

chapter_07.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -435,14 +435,14 @@ import matplotlib.pyplot as plt
435435
import matplotlib.patches as mpatches
436436
from matplotlib.patches import FancyBboxPatch, FancyArrowPatch
437437
438-
fig, ax = plt.subplots(figsize=(10, 6))
438+
fig, ax = plt.subplots(figsize=(12, 7))
439439
ax.set_xlim(0, 10)
440440
ax.set_ylim(0, 10)
441441
ax.axis('off')
442442
443443
# Title
444444
ax.text(5, 9.5, r'Binomial Formula Breakdown: $n=3, k=2, p=0.6$',
445-
ha='center', va='top', fontsize=14, weight='bold')
445+
ha='center', va='top', fontsize=16, weight='bold')
446446
447447
# Draw the three sequences
448448
sequences = [
@@ -464,47 +464,47 @@ for seq_text, x, y in sequences:
464464
465465
# Sequence text
466466
ax.text(x, y, seq_text, ha='center', va='center',
467-
fontsize=12, weight='bold', family='monospace')
467+
fontsize=14, weight='bold', family='monospace')
468468
469469
# Probability calculation below
470470
ax.text(x, y-0.8, f'{p}×{p}×{1-p:.1f}', ha='center', va='top',
471-
fontsize=10, style='italic')
471+
fontsize=12, style='italic')
472472
ax.text(x, y-1.2, f'= {prob_each:.3f}', ha='center', va='top',
473-
fontsize=10, weight='bold')
473+
fontsize=12, weight='bold')
474474
475475
# Count annotation
476476
ax.text(5, 5.5, r'$\binom{3}{2} = 3$ sequences',
477-
ha='center', va='center', fontsize=12, weight='bold',
477+
ha='center', va='center', fontsize=13, weight='bold',
478478
bbox=dict(boxstyle='round', facecolor='lightyellow', edgecolor='orange', linewidth=2))
479479
480480
# Formula breakdown
481-
ax.text(5, 4.2, 'Formula:', ha='center', va='center', fontsize=11, weight='bold')
481+
ax.text(5, 4.2, 'Formula:', ha='center', va='center', fontsize=13, weight='bold')
482482
ax.text(5, 3.6, r'$P(X=2) = \binom{3}{2} \cdot p^2 \cdot (1-p)^1$',
483-
ha='center', va='center', fontsize=12)
483+
ha='center', va='center', fontsize=13)
484484
ax.text(5, 2.9, r'$= 3 \times 0.36 \times 0.4$',
485-
ha='center', va='center', fontsize=11)
485+
ha='center', va='center', fontsize=13)
486486
ax.text(5, 2.3, r'$= 0.432$',
487-
ha='center', va='center', fontsize=12, weight='bold',
487+
ha='center', va='center', fontsize=14, weight='bold',
488488
bbox=dict(boxstyle='round', facecolor='lightgreen', edgecolor='green', linewidth=2))
489489
490-
# Annotations with arrows - adjusted to avoid overlaps
491-
ax.annotate('Count sequences', xy=(4.2, 5.5), xytext=(1.2, 6.2),
490+
# Annotations with arrows - repositioned to avoid all overlaps
491+
ax.annotate('Count sequences', xy=(4.0, 5.5), xytext=(0.5, 4.8),
492492
arrowprops=dict(arrowstyle='->', color='orange', lw=2),
493-
fontsize=9, color='orange', weight='bold')
493+
fontsize=11, color='orange', weight='bold')
494494
495-
ax.annotate('Each sequence\nhas same\nprobability', xy=(7.5, 6.5), xytext=(8.5, 8),
495+
ax.annotate('Each sequence\nhas same\nprobability', xy=(8.1, 7), xytext=(8.5, 8.5),
496496
arrowprops=dict(arrowstyle='->', color='steelblue', lw=2),
497-
fontsize=9, color='steelblue', weight='bold', ha='center')
497+
fontsize=11, color='steelblue', weight='bold', ha='left')
498498
499-
ax.annotate('Multiply!', xy=(5.8, 2.3), xytext=(7.5, 3.2),
499+
ax.annotate('Multiply!', xy=(6.0, 2.5), xytext=(7.8, 1.8),
500500
arrowprops=dict(arrowstyle='->', color='green', lw=2),
501-
fontsize=9, color='green', weight='bold')
501+
fontsize=11, color='green', weight='bold')
502502
503503
# Bottom explanation
504-
ax.text(5, 1.2, 'Why it works: Each sequence occurs with probability 0.432/3 = 0.144,',
505-
ha='center', va='center', fontsize=9, style='italic')
506-
ax.text(5, 0.7, 'and there are 3 ways to get exactly 2 successes, so total = 3 × 0.144 = 0.432',
507-
ha='center', va='center', fontsize=9, style='italic')
504+
ax.text(5, 1.0, 'Why it works: Each sequence occurs with probability 0.432/3 = 0.144,',
505+
ha='center', va='center', fontsize=11, style='italic')
506+
ax.text(5, 0.5, 'and there are 3 ways to get exactly 2 successes, so total = 3 × 0.144 = 0.432',
507+
ha='center', va='center', fontsize=11, style='italic')
508508
509509
plt.tight_layout()
510510
plt.savefig('ch07_binomial_formula_breakdown.svg', format='svg', bbox_inches='tight')

0 commit comments

Comments
 (0)