import numpy as np
import matplotlib.pyplot as plt
plt.figure(figsize=(12, 10))
plt.style.use('seaborn-whitegrid')
np.random.seed(2024)
total_cells = 50000
populations = [
('Viable', 0.68, (18, 4), (17, 3), '#3575D5', 'Viable (68%)'),
('Early Apoptosis',0.10, (72, 7), (25, 5), '#4CAF50', 'Early Apoptosis (10%)'),
('Late Apoptosis', 0.20, (68, 8), (75, 8), '#E53935', 'Late Apoptosis (20%)'),
('Necrosis', 0.02, (22, 5), (78, 6), '#AB47BC', 'Necrosis (2%)')
]
for label, ratio, x_params, y_params, color, legend_label in populations:
n = int(total_cells * ratio)
x = np.random.normal(x_params[0], x_params[1], n)
y = np.random.normal(y_params[0], y_params[1], n)
plt.scatter(x, y, s=6, alpha=0.3, color=color, edgecolors='none', label=legend_label)
plt.axvline(45, color='black', linestyle='--', linewidth=1.5, alpha=0.7)
plt.axhline(45, color='black', linestyle='--', linewidth=1.5, alpha=0.7)
annotations = [
(20, 20, 'Viable\n68%', '#3575D5'),
(75, 20, 'Early\nApoptosis\n10%', '#4CAF50'),
(75, 75, 'Late\nApoptosis\n20%', '#E53935'),
(20, 75, 'Necrosis\n2%', '#AB47BC')
]
for x, y, text, color in annotations:
plt.text(x, y, text,
ha='center', va='center',
fontsize=11,
color='black',
bbox=dict(boxstyle='round',
facecolor='white',
alpha=0.8,
edgecolor=color))
plt.xlabel('Annexin V-FITC Intensity (a.u.)', fontsize=13, labelpad=12)
plt.ylabel('Propidium Iodide (PI) Intensity (a.u.)', fontsize=13, labelpad=12)
plt.xlim(0, 100)
plt.ylim(0, 100)
plt.xticks(np.arange(0, 101, 10), fontsize=10)
plt.yticks(np.arange(0, 101, 10), fontsize=10)
legend = plt.legend(
loc='upper right',
frameon=True,
framealpha=0.95,
edgecolor='#333333',
fontsize=12,
markerscale=3,
title='Cell Populations',
title_fontsize=13
)
legend.get_frame().set_linewidth(1.5)
plt.savefig('LargeScale_Apoptosis_Plot.png',
dpi=300,
bbox_inches='tight',
facecolor='white')
plt.show()