Bar Chart

Minimal Horizontal Bar

Clean horizontal bar chart with percentage labels.

Output
Minimal Horizontal Bar
Python
import matplotlib.pyplot as plt
import numpy as np

COLORS = {
    'primary': '#8B5CF6',
    'background': '#FFFFFF',
    'text': '#1E293B',
    'text_muted': '#64748B',
    'grid': '#F1F5F9',
}

items = ['Item A', 'Item B', 'Item C', 'Item D', 'Item E']
values = [92, 78, 65, 54, 43]
y = np.arange(len(items))

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

ax.barh(y, values, height=0.5, color=COLORS['primary'], alpha=0.85,
        edgecolor='white', linewidth=2, zorder=3)

for yi, v in zip(y, values):
    ax.text(v + 2, yi, f'{v}%', ha='left', va='center', fontsize=10,
            fontweight='bold', color=COLORS['text'])

ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['left'].set_visible(False)
ax.spines['bottom'].set_color(COLORS['grid'])

ax.tick_params(axis='y', left=False, colors=COLORS['text'], labelsize=10, pad=8)
ax.tick_params(axis='x', colors=COLORS['text_muted'], labelsize=9, length=0, pad=8)

ax.set_yticks(y)
ax.set_yticklabels(items)
ax.set_xlim(0, 110)

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Basic Charts

Did this help you?

Support PyLucid to keep it free & growing

Support