Bar Chart

Dumbbell Chart

Showing change between two time points

Output
Dumbbell Chart
Python
import matplotlib.pyplot as plt
import numpy as np

categories = ['Engineering', 'Marketing', 'Sales', 'Support', 'Design', 'HR', 'Finance']
before = [65, 55, 70, 45, 60, 50, 58]
after = [78, 72, 75, 68, 82, 62, 71]

fig, ax = plt.subplots(figsize=(10, 7), facecolor='#0a0a0f')
ax.set_facecolor('#0a0a0f')

y_pos = np.arange(len(categories))

for i, (b, a) in enumerate(zip(before, after)):
    ax.plot([b, a], [i, i], color='#333333', linewidth=2, zorder=1)

ax.scatter(before, y_pos, color='#F5276C', s=100, zorder=2, label='2023')
ax.scatter(after, y_pos, color='#6CF527', s=100, zorder=2, label='2024')

for i, (b, a) in enumerate(zip(before, after)):
    change = a - b
    color = '#6CF527' if change > 0 else '#F5276C'
    ax.text(a + 3, i, f'+{change}' if change > 0 else str(change), 
            va='center', color=color, fontsize=9, fontweight='bold')

ax.set_yticks(y_pos)
ax.set_yticklabels(categories, color='white', fontsize=10)
ax.set_xlabel('Employee Satisfaction Score', color='#888888', fontsize=11)
ax.set_xlim(35, 95)

ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['left'].set_color('#333333')
ax.spines['bottom'].set_color('#333333')
ax.tick_params(axis='both', colors='#888888', labelsize=9)
ax.xaxis.grid(True, color='#1a1a2e', linewidth=0.5)
ax.set_axisbelow(True)

ax.legend(loc='lower right', frameon=False, labelcolor='white', fontsize=9)
ax.set_title('Department Satisfaction Change', color='white', fontsize=14, fontweight='bold', pad=15)
plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Basic Charts

Did this help you?

Support PyLucid to keep it free & growing

Support