Raincloud Plot

Response Rate by Survey Type

Completion rates across survey methods

Output
Response Rate by Survey Type
Python
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import ptitprince as pt

np.random.seed(218)
BG_COLOR = '#ffffff'
TEXT_COLOR = '#1f2937'
COLORS = ['#F5276C', '#F5B027', '#27F5B0']

types = ['Email', 'Phone', 'In-Person']
data = pd.DataFrame({
    'Rate': np.concatenate([
        np.random.beta(3, 7, 100) * 100,
        np.random.beta(5, 5, 80) * 100,
        np.random.beta(7, 3, 60) * 100
    ]),
    'Type': ['Email']*100 + ['Phone']*80 + ['In-Person']*60
})

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

pt.RainCloud(x='Type', y='Rate', 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 Rate (%)', fontsize=12, color=TEXT_COLOR, fontweight='500')
ax.set_ylabel('Survey Type', fontsize=12, color=TEXT_COLOR, fontweight='500')
ax.set_title('Survey Response Rate by Method', fontsize=14, color=TEXT_COLOR, fontweight='bold', pad=15)

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

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support