Bar Chart
Diverging Growth Bars
Diverging bars showing positive and negative values
Output
Python
import matplotlib.pyplot as plt
import numpy as np
np.random.seed(42)
categories = ['Region A', 'Region B', 'Region C', 'Region D', 'Region E',
'Region F', 'Region G', 'Region H', 'Region I', 'Region J']
values = np.random.uniform(-50, 50, len(categories))
values = np.sort(values)
fig, ax = plt.subplots(figsize=(10, 7), facecolor='#0a0a0f')
ax.set_facecolor('#0a0a0f')
colors = ['#F5276C' if v < 0 else '#6CF527' for v in values]
y_pos = np.arange(len(categories))
ax.barh(y_pos, values, color=colors, height=0.7, edgecolor='none')
for i, v in enumerate(values):
offset = 2 if v >= 0 else -2
ha = 'left' if v >= 0 else 'right'
ax.text(v + offset, i, f'{v:.1f}%', va='center', ha=ha, color='white', fontsize=9)
ax.axvline(x=0, color='#444444', linewidth=1)
ax.set_yticks(y_pos)
ax.set_yticklabels(categories, color='white', fontsize=10)
ax.set_xlabel('Growth Rate (%)', color='#888888', 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('#333333')
ax.tick_params(axis='x', colors='#888888', labelsize=9)
ax.tick_params(axis='y', length=0)
ax.xaxis.grid(True, color='#1a1a2e', linewidth=0.5)
ax.set_axisbelow(True)
ax.set_title('Regional Growth Analysis', color='white', fontsize=14, fontweight='bold', pad=15)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
Basic Charts
More Bar Chart examples
☕