Area Chart

Gaussian Peaks

Multiple gaussian peaks visualization.

Output
Gaussian Peaks
Python
import matplotlib.pyplot as plt
import numpy as np

# Data - Multiple gaussian peaks (spectroscopy)
x = np.linspace(400, 700, 500)

def gaussian(x, mu, sigma, amp):
    return amp * np.exp(-(x - mu)**2 / (2 * sigma**2))

peaks = [(450, 15, 0.8), (520, 20, 1.0), (580, 12, 0.6), (650, 18, 0.9)]
colors = ['#4927F5', '#27D3F5', '#6CF527', '#F5276C']

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

# Individual peaks
total = np.zeros_like(x)
for (mu, sigma, amp), color in zip(peaks, colors):
    y = gaussian(x, mu, sigma, amp)
    total += y
    ax.fill_between(x, 0, y, alpha=0.4, color=color)
    ax.plot(x, y, color=color, linewidth=1.5)

# Total signal
ax.plot(x, total, color='#1f2937', linewidth=2, linestyle='--', label='Sum')

# Styling
ax.set_xlabel('Wavelength (nm)', color='#1f2937', fontsize=11)
ax.set_ylabel('Intensity (a.u.)', color='#1f2937', fontsize=11)
ax.set_title('Spectral Decomposition', color='#1f2937', fontsize=14, fontweight='bold', pad=15)
ax.tick_params(colors='#374151', labelsize=9)
for spine in ax.spines.values():
    spine.set_color('#e5e7eb')
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.yaxis.grid(True, color='#f3f4f6', linewidth=0.5)
ax.set_xlim(400, 700)
ax.legend(facecolor='#ffffff', edgecolor='#e5e7eb', labelcolor='#1f2937')

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Basic Charts

Did this help you?

Support PyLucid to keep it free & growing

Support