Event Plot
Pulsar Signal Detection
Radio telescope pulsar timing observations
Output
Python
import matplotlib.pyplot as plt
import numpy as np
# Simulate pulsar signals
np.random.seed(42)
pulsars = ['PSR B1919+21', 'PSR J0437-4715', 'Crab Pulsar', 'Vela Pulsar']
periods = [1.337, 0.00575, 0.0334, 0.0893] # seconds
pulses = []
for period in periods:
n_pulses = int(10 / period)
base = np.arange(n_pulses) * period
jitter = np.random.normal(0, period * 0.01, n_pulses)
pulses.append(base + jitter)
# Colors
colors = ['#F59E0B', '#3B82F6', '#EF4444', '#10B981']
# Create dark space theme
fig, ax = plt.subplots(figsize=(12, 5), facecolor='#030712')
ax.set_facecolor('#030712')
# Stars background
for _ in range(100):
ax.scatter(np.random.uniform(0, 10), np.random.uniform(-0.5, 3.5),
s=np.random.uniform(0.2, 1), c='white', alpha=np.random.uniform(0.2, 0.6))
for i, (p, color, period) in enumerate(zip(pulses, colors, periods)):
# Glow effect
for lw, alpha in [(8, 0.1), (4, 0.3), (2, 0.6)]:
ax.eventplot(p, lineoffsets=i, linelengths=0.6, linewidths=lw,
colors=color, alpha=alpha)
# Period annotation
ax.text(10.2, i, f'P={period*1000:.1f}ms', fontsize=9, va='center',
color=color, fontweight='500')
# Styling
ax.set_yticks(range(len(pulsars)))
ax.set_yticklabels(pulsars, fontsize=10, fontweight='500', color='white',
family='monospace')
ax.set_xlabel('Time (seconds)', fontsize=12, fontweight='500', color='#9CA3AF')
ax.set_xlim(0, 11)
ax.set_ylim(-0.5, len(pulsars) - 0.5)
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['left'].set_color('#1F2937')
ax.spines['bottom'].set_color('#1F2937')
ax.tick_params(colors='#9CA3AF', labelsize=10)
ax.xaxis.grid(True, linestyle='--', alpha=0.1, color='#4B5563')
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
Statistical
More Event Plot examples
☕