Faceted Scatter Plot

Clinical Trial Response Rates

Clinical trial response rates across therapeutic interventions

Output
Clinical Trial Response Rates
Python
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np

np.random.seed(999)

treatments = ['Standard', 'Experimental', 'Combination', 'Placebo']
data = []
for treat in treatments:
    n = 42
    dosage = np.random.uniform(10, 100, n)
    efficacy = {'Standard': 0.6, 'Experimental': 0.75, 'Combination': 0.85, 'Placebo': 0.15}
    response = efficacy[treat] * np.log(dosage + 1) * 10 + np.random.normal(0, 5, n)
    response = np.clip(response, 0, 100)
    for d, r in zip(dosage, response):
        data.append({'Dosage (mg)': d, 'Response Score': r, 'Treatment': treat})

df = pd.DataFrame(data)

sns.set_style("whitegrid", {
    'axes.facecolor': '#ffffff',
    'figure.facecolor': '#ffffff',
    'grid.color': '#eeeeee'
})

palette = ['#276CF5', '#F5276C', '#5314E6', '#888888']

g = sns.lmplot(
    data=df,
    x='Dosage (mg)',
    y='Response Score',
    hue='Treatment',
    col='Treatment',
    col_wrap=2,
    height=3.5,
    aspect=1.2,
    palette=palette,
    scatter_kws={'alpha': 0.7, 's': 50, 'edgecolor': 'white', 'linewidths': 0.6},
    line_kws={'linewidth': 2.5},
    ci=95
)

g.fig.set_facecolor('#ffffff')
for ax in g.axes.flat:
    ax.set_facecolor('#ffffff')
    for spine in ax.spines.values():
        spine.set_color('#dddddd')

g.fig.suptitle('Therapeutic Efficacy Comparison', fontsize=14, fontweight='bold', color='#1a1a1a', 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