Correlogram
Cancer Biomarker Correlations
Multi-variable correlation matrix of tumor biomarkers by cancer stage
Output
Python
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np
np.random.seed(42)
# Simulated biomarker data
n = 150
stages = np.random.choice(['Stage I', 'Stage II', 'Stage III'], n)
data = {
'CEA': np.where(stages == 'Stage I', np.random.normal(3, 1, n),
np.where(stages == 'Stage II', np.random.normal(8, 2, n), np.random.normal(15, 4, n))),
'CA19-9': np.where(stages == 'Stage I', np.random.normal(20, 8, n),
np.where(stages == 'Stage II', np.random.normal(50, 15, n), np.random.normal(100, 30, n))),
'AFP': np.random.normal(5, 2, n) + np.random.uniform(0, 10, n),
'PSA': np.random.normal(2, 0.8, n) + np.random.uniform(0, 3, n),
'Stage': stages
}
df = pd.DataFrame(data)
# Dark theme
plt.style.use('dark_background')
sns.set_style("darkgrid", {
'axes.facecolor': '#0a0a0f',
'figure.facecolor': '#0a0a0f',
'grid.color': '#333333'
})
palette = {'Stage I': '#6CF527', 'Stage II': '#F5B027', 'Stage III': '#F5276C'}
g = sns.pairplot(
df,
hue='Stage',
palette=palette,
height=2,
kind='scatter',
diag_kind='kde',
markers=['o', 's', 'D'],
plot_kws={'alpha': 0.7, 's': 50, 'edgecolor': 'white', 'linewidths': 0.5},
diag_kws={'alpha': 0.6, 'linewidth': 2},
corner=False
)
g.fig.set_facecolor('#0a0a0f')
for ax in g.axes.flat:
if ax:
ax.set_facecolor('#0a0a0f')
for spine in ax.spines.values():
spine.set_color('#333333')
ax.tick_params(colors='#888888')
ax.xaxis.label.set_color('white')
ax.yaxis.label.set_color('white')
g.fig.suptitle('Tumor Biomarker Correlations', fontsize=14, fontweight='bold', color='white', y=1.02)
g._legend.set_title('Stage')
plt.setp(g._legend.get_title(), color='white')
plt.setp(g._legend.get_texts(), color='white')
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
Statistical
More Correlogram examples
☕