Histogram

Distribution Mirror

Symmetric histogram pyramid.

Output
Distribution Mirror
Python
import matplotlib.pyplot as plt
import numpy as np

COLORS = {'left': '#374151', 'right': '#EC4899', 'background': '#FFFFFF', 'text': '#1E293B', 'text_muted': '#64748B', 'grid': '#F1F5F9'}

np.random.seed(42)
data = np.random.normal(0, 1, 1000)
bins = np.linspace(-4, 4, 25)
counts, _ = np.histogram(data, bins=bins)

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

bin_centers = (bins[:-1] + bins[1:]) / 2
ax.barh(bin_centers, -counts, height=0.3, color=COLORS['left'])
ax.barh(bin_centers, counts, height=0.3, color=COLORS['right'])

ax.axvline(0, color=COLORS['text'], linewidth=1)
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['left'].set_color(COLORS['grid'])
ax.spines['bottom'].set_color(COLORS['grid'])
ax.tick_params(axis='both', colors=COLORS['text_muted'], labelsize=9, length=0, pad=8)
ax.set_xlabel('Frequency', fontsize=10, color=COLORS['text'], labelpad=10)
ax.set_ylabel('Standard Deviations', fontsize=10, color=COLORS['text'], labelpad=10)

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Basic Charts

Did this help you?

Support PyLucid to keep it free & growing

Support