Faceted Scatter Plot

Gene Expression by Tissue

Multi-panel regression of biomarker levels across organ systems

Output
Gene Expression by Tissue
Python
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np

np.random.seed(123)

tissues = ['Brain', 'Liver', 'Heart', 'Kidney']
data = []
for tissue in tissues:
    n = 35
    age = np.random.uniform(20, 80, n)
    slopes = {'Brain': -0.015, 'Liver': -0.02, 'Heart': -0.012, 'Kidney': -0.018}
    expression = 100 + slopes[tissue] * age * 10 + np.random.normal(0, 8, n)
    for a, e in zip(age, expression):
        data.append({'Age': a, 'Expression Level': e, 'Tissue': tissue})

df = pd.DataFrame(data)

plt.style.use('dark_background')
sns.set_style("darkgrid", {
    'axes.facecolor': '#0a0a0f',
    'figure.facecolor': '#0a0a0f',
    'grid.color': '#333333'
})

palette = ['#5314E6', '#F5D327', '#27F5B0', '#C82909']

g = sns.lmplot(
    data=df,
    x='Age',
    y='Expression Level',
    hue='Tissue',
    col='Tissue',
    col_wrap=2,
    height=3.5,
    aspect=1.2,
    palette=palette,
    scatter_kws={'alpha': 0.75, 's': 45, 'edgecolor': 'white', 'linewidths': 0.4},
    line_kws={'linewidth': 2.5},
    ci=95
)

g.fig.set_facecolor('#0a0a0f')
for ax in g.axes.flat:
    ax.set_facecolor('#0a0a0f')
    for spine in ax.spines.values():
        spine.set_color('#333333')

g.fig.suptitle('Age-Related Gene Expression Decline', fontsize=14, fontweight='bold', color='white', y=1.02)
plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Pairwise Data

Did this help you?

Support PyLucid to keep it free & growing

Support