Boxplot
Observatory Time Allocation
Telescope observation hours by astronomical survey type
Output
Python
import matplotlib.pyplot as plt
import numpy as np
np.random.seed(42)
surveys = ['Exoplanet', 'Galaxy', 'Supernova', 'Dark Matter', 'Pulsar']
data = [
np.random.gamma(3, 2, 100),
np.random.gamma(4, 2.5, 100),
np.random.gamma(2, 3, 100),
np.random.gamma(5, 3, 100),
np.random.gamma(2.5, 1.5, 100)
]
fig, ax = plt.subplots(figsize=(10, 6), dpi=100)
ax.set_facecolor('#0a0a0f')
fig.patch.set_facecolor('#0a0a0f')
colors = ['#27D3F5', '#5314E6', '#F54927', '#4927F5', '#6CF527']
bp = ax.boxplot(data, widths=0.55, patch_artist=True, showfliers=True,
flierprops=dict(marker='*', markerfacecolor='#F5D327', markersize=6, alpha=0.7),
medianprops=dict(color='white', linewidth=2))
for patch, color in zip(bp['boxes'], colors):
patch.set_facecolor(color)
patch.set_alpha(0.85)
patch.set_edgecolor(color)
patch.set_linewidth(1.5)
for i, color in enumerate(colors):
bp['whiskers'][i*2].set_color(color)
bp['whiskers'][i*2+1].set_color(color)
bp['caps'][i*2].set_color(color)
bp['caps'][i*2+1].set_color(color)
for i, d in enumerate(data):
ax.scatter([i+1]*len(d), d, alpha=0.1, s=6, color=colors[i], zorder=1)
ax.set_xticklabels(surveys)
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['left'].set_color('#333333')
ax.spines['bottom'].set_color('#333333')
ax.yaxis.grid(True, color='#1a1a2e', linewidth=0.5, zorder=0)
ax.set_axisbelow(True)
ax.tick_params(axis='both', colors='#888888', labelsize=9, length=0, pad=8)
ax.set_ylabel('Observation Hours', fontsize=11, color='white', fontweight='500')
ax.set_title('Telescope Time Allocation by Survey', fontsize=14, color='white', fontweight='bold', pad=15)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
Statistical
More Boxplot examples
☕