Raincloud Plot

Social Media Engagement by Post Type

Interaction rates across content formats

Output
Social Media Engagement by Post Type
Python
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import ptitprince as pt

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

types = ['Image', 'Video', 'Carousel', 'Story']
data = pd.DataFrame({
    'Engagement': np.concatenate([
        np.random.lognormal(1.5, 0.6, 100),
        np.random.lognormal(2.0, 0.7, 90),
        np.random.lognormal(1.8, 0.5, 85),
        np.random.lognormal(2.2, 0.8, 75)
    ]),
    'Type': ['Image']*100 + ['Video']*90 + ['Carousel']*85 + ['Story']*75
})

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

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

ax.set_xlabel('Engagement Rate (%)', fontsize=12, color=TEXT_COLOR, fontweight='500')
ax.set_ylabel('Post Type', fontsize=12, color=TEXT_COLOR, fontweight='500')
ax.set_title('Social Media Engagement by Format', 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