Bar Chart

Horizontal Bar Rankings

Clean horizontal bars with value labels

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

categories = ['Product Alpha', 'Product Beta', 'Product Gamma', 'Product Delta', 
              'Product Epsilon', 'Product Zeta', 'Product Eta']
values = [89, 76, 72, 68, 55, 48, 42]

fig, ax = plt.subplots(figsize=(10, 6), facecolor='#ffffff')
ax.set_facecolor('#ffffff')

y_pos = np.arange(len(categories))
colors = plt.cm.Blues(np.linspace(0.4, 0.9, len(categories)))[::-1]

bars = ax.barh(y_pos, values, height=0.65, color=colors, edgecolor='none')

for i, (bar, v) in enumerate(zip(bars, values)):
    ax.text(v + 1.5, i, f'{v}%', va='center', color='#374151', fontsize=10, fontweight='500')

ax.set_yticks(y_pos)
ax.set_yticklabels(categories, color='#374151', fontsize=10)
ax.set_xlim(0, 100)
ax.set_xlabel('Market Share (%)', color='#6b7280', fontsize=11)

ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['left'].set_visible(False)
ax.spines['bottom'].set_color('#e5e7eb')
ax.tick_params(axis='x', colors='#6b7280', labelsize=9)
ax.tick_params(axis='y', length=0)
ax.xaxis.grid(True, color='#f3f4f6', linewidth=1)
ax.set_axisbelow(True)

ax.set_title('Product Market Share', color='#1f2937', 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