Ridgeline Plot

Temperature Distribution by Month

Monthly temperature variations showing seasonal patterns

Output
Temperature Distribution by Month
Python
import matplotlib.pyplot as plt
import numpy as np
from scipy import stats

np.random.seed(42)
months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
base_temps = [5, 7, 12, 16, 20, 25, 28, 27, 23, 17, 11, 6]

fig, ax = plt.subplots(figsize=(12, 10), facecolor='#0a0a0f')
ax.set_facecolor('#0a0a0f')

colors = ['#27D3F5', '#27F5B0', '#6CF527', '#D3F527', '#F5B027', '#F54927', 
          '#F5276C', '#F527B0', '#4927F5', '#276CF5', '#27D3F5', '#27F5B0']

x = np.linspace(-10, 45, 200)
overlap = 2.5

for i, (month, base, color) in enumerate(zip(months, base_temps, colors)):
    data = np.random.normal(base, 4, 1000)
    kde = stats.gaussian_kde(data)
    y = kde(x) * 12
    y_offset = i * overlap
    
    ax.fill_between(x, y_offset, y + y_offset, alpha=0.85, color=color, edgecolor='white', linewidth=0.8)
    ax.text(-14, y_offset + 0.3, month, fontsize=10, color='white', va='center', ha='right', fontweight='500')

ax.set_xlim(-18, 45)
ax.set_ylim(-0.5, len(months) * overlap + 3)
ax.set_xlabel('Temperature (°C)', color='white', fontsize=11, fontweight='500')
ax.set_title('Temperature Distribution by Month', color='white', fontsize=14, fontweight='bold', pad=20)
ax.tick_params(colors='#888888', labelsize=9)
ax.set_yticks([])
for spine in ax.spines.values():
    spine.set_visible(False)
ax.spines['bottom'].set_visible(True)
ax.spines['bottom'].set_color('#333333')

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support