import matplotlib.pyplot as plt
import matplotlib.patches as patches
import matplotlib.lines as mlines
import random
fig, ax = plt.subplots(figsize=(16, 10), facecolor='#0f0f1f')
ax.set_facecolor('#0f0f1f')
ax.set_xlim(0, 12)
ax.set_ylim(0, 10)
ax.axis('off')
plt.title('Cosmic Evolution from Primordial QGP to Galaxies',
fontsize=20, color='white', pad=20, fontweight='bold')
stages = [
{"name": "Quark-Gluon Plasma",
"details": "Age: 10⁻¹²-10⁻⁶s\nTemp: >10¹²K\nFree quarks & gluons"},
{"name": "Hadronization",
"details": "Age: ~10⁻⁵s\nTemp: ~10¹²K\nQuarks → hadrons"},
{"name": "Lepton Era",
"details": "Age: 1s-1min\ne⁻/ν dominate\nPhoton scattering"},
{"name": "Nucleosynthesis",
"details": "Age: 3-20min\nForms H, He, Li\n75% H, 25% He"},
{"name": "Radiation Plasma",
"details": "Age: ~50k years\nIons + free e⁻\nOpaque universe"},
{"name": "Recombination",
"details": "Age: 380k years\nNeutral atoms\nCMB release"},
{"name": "Dark Ages",
"details": "Neutral gas\nNo light\nCosmic darkness"},
{"name": "First Stars & Galaxies",
"details": "Age: 200M-1B yr\nPop III stars\nGalaxy formation"},
{"name": "Modern Universe",
"details": "Galaxies\nHeavy elements\nSolar systems"}
]
positions = [ (1.0, 8.0), (3.5, 8.0), (5.5, 8.0), (7.5, 8.0), (9.5, 8.0), (9.5, 6.5), (9.5, 5.0), (9.5, 3.5), (9.5, 2.0)]
colors = ['#ffd1dc', '#e6e6fa', '#d1f0ff', '#d1e0ff', '#d0f0fd', '#e0f7fa', '#f0f8ff', '#ffe4b5', '#fffacd']
arrow_style = {'arrowstyle': '->', 'color': '#4cc9f0', 'lw': 2, 'alpha': 0.8}
for i in range(4):
if i == 3:
end_x = 8.7
else:
end_x = positions[i+1][0]
ax.annotate('', xy=(end_x, 8.7), xytext=(positions[0], 8.7), arrowprops=arrow_style)
ax.annotate('', xy=(8.7, 8.0), xytext=(8.7, 8.7), arrowprops=arrow_style)
vertical_y_positions = [8.0, 6.5, 5.0, 3.5, 2.0]
for i in range(1, 5):
ax.annotate('',
xy=(8.7, vertical_y_positions),
xytext=(8.7, vertical_y_positions[i-1]),
arrowprops=arrow_style)
for i, stage in enumerate(stages):
x, y = positions
box = patches.FancyBboxPatch((x-1.2, y-0.5), 2.4, 1.0,
boxstyle="round,pad=0.3,rounding_size=0.2",
ec="black", fc=colors, alpha=0.95)
ax.add_patch(box)
plt.text(x, y+0.2, stage['name'],
ha='center', va='center',
color='black', fontweight='bold', fontsize=10)
plt.text(x, y-0.2, stage['details'],
ha='center', va='center',
color='black', fontsize=9)
for _ in range(200):
x = random.uniform(0, 12)
y = random.uniform(0, 10)
size = random.uniform(1, 50)
alpha = size * 0.002
ax.scatter(x, y, s=size, c='white', alpha=alpha)
plt.text(0.7, 9.0, "EARLY UNIVERSE →", color='#f72585', fontsize=12, alpha=0.9)
plt.text(11.2, 2.0, "LATE UNIVERSE ↓", color="#ee4343", fontsize=12, rotation=0, alpha=0.9)
physics_notes = [
(2.1, 7.3, "QCD Phase Transition"),
(4.1, 7.3, "Matter Dominance"),
(6.1, 7.3, "Deuterium Bottleneck"),
(10.0, 7.3, "Thomson Scattering"),
(10.0,5.9,"Photon Decoupling"),
(10.0, 4.4,"Structure Formation"),
(10.0,2.9, "Pop III Stars"),
(10.0,1.3,"Metal Enrichment")
]
for x, y, text in physics_notes:
plt.text(x, y, text, color='#90e0ef', fontsize=9, alpha=0.9,
bbox=dict(boxstyle="round,pad=0.2", fc='#1e1e2e', ec='none', alpha=0.7))
plt.text(9.5, 7.4, "▼ TRANSITION ▼",
ha='center', color='#4cc9f0', fontsize=10, alpha=0.8)
plt.text(6, 0.8, "Based on ΛCDM Cosmology | Data: Planck Satellite, WMAP",
ha='center', color='#a0a0c0', fontsize=10, alpha=0.7)
plt.tight_layout()
plt.savefig('cosmic_evolution_horizontal_to_vertical.png', dpi=300, facecolor='#0f0f1f')
plt.show()