Raincloud Plot

Drug Response Time by Treatment Group

Clinical trial response times across treatment arms

Output
Drug Response Time by Treatment Group
Python
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import ptitprince as pt

np.random.seed(101)
BG_COLOR = '#0a0a0f'
TEXT_COLOR = 'white'
COLORS = ['#F5276C', '#27D3F5', '#6CF527']

groups = ['Placebo', 'Low Dose', 'High Dose']
data = pd.DataFrame({
    'Response Time': np.concatenate([
        np.random.normal(45, 12, 80),
        np.random.normal(35, 10, 85),
        np.random.normal(25, 8, 90)
    ]),
    'Group': ['Placebo']*80 + ['Low Dose']*85 + ['High Dose']*90
})

fig, ax = plt.subplots(figsize=(10, 6), facecolor=BG_COLOR)
ax.set_facecolor(BG_COLOR)

pt.RainCloud(x='Group', y='Response Time', data=data, palette=COLORS,
             bw=.2, width_viol=.6, ax=ax, orient='h', alpha=.65,
             dodge=True, pointplot=False, move=.2)

ax.set_xlabel('Response Time (days)', fontsize=12, color=TEXT_COLOR, fontweight='500')
ax.set_ylabel('Treatment Group', fontsize=12, color=TEXT_COLOR, fontweight='500')
ax.set_title('Drug Response Time by Treatment', fontsize=14, color=TEXT_COLOR, fontweight='bold', pad=15)

ax.tick_params(colors='#888', labelsize=10)
for spine in ax.spines.values():
    spine.set_color('#333')

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support