Bar Chart

Bullet Chart

Performance against target with qualitative ranges.

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

COLORS = {
    'actual': '#6366F1',
    'target': '#EF4444',
    'ranges': ['#E2E8F0', '#CBD5E1', '#94A3B8'],
    'background': '#FFFFFF',
    'text': '#1E293B',
    'text_muted': '#64748B',
}

metrics = ['Revenue', 'Profit', 'Customers']
actuals = [270, 85, 180]
targets = [250, 100, 200]
ranges_data = [
    [200, 250, 300],
    [50, 80, 100],
    [150, 175, 220],
]

fig, axes = plt.subplots(3, 1, figsize=(10, 5), dpi=100)
fig.patch.set_facecolor(COLORS['background'])

for ax, metric, actual, target, ranges in zip(axes, metrics, actuals, targets, ranges_data):
    ax.set_facecolor(COLORS['background'])
    
    # Range backgrounds
    ax.barh(0, ranges[2], height=0.6, color=COLORS['ranges'][0], zorder=1)
    ax.barh(0, ranges[1], height=0.6, color=COLORS['ranges'][1], zorder=2)
    ax.barh(0, ranges[0], height=0.6, color=COLORS['ranges'][2], zorder=3)
    
    # Actual bar
    ax.barh(0, actual, height=0.3, color=COLORS['actual'], zorder=4)
    
    # Target marker
    ax.axvline(target, color=COLORS['target'], linewidth=3, ymin=0.2, ymax=0.8, zorder=5)
    
    ax.text(-10, 0, metric, ha='right', va='center', fontsize=10, 
            fontweight='bold', color=COLORS['text'])
    ax.text(actual + 5, 0, str(actual), ha='left', va='center', fontsize=9, 
            color=COLORS['text'])
    
    ax.set_xlim(-80, ranges[2] * 1.1)
    ax.set_ylim(-0.5, 0.5)
    ax.axis('off')

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Basic Charts

Did this help you?

Support PyLucid to keep it free & growing

Support