Correlogram

Environmental Sensor Network

Air quality parameter correlations across monitoring stations

Output
Environmental Sensor Network
Python
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np

np.random.seed(321)

n = 170
zones = np.random.choice(['Urban', 'Suburban', 'Rural'], n)
data = {
    'PM2.5': np.where(zones == 'Urban', np.random.normal(45, 15, n),
                     np.where(zones == 'Suburban', np.random.normal(25, 8, n), np.random.normal(12, 4, n))),
    'NO2': np.where(zones == 'Urban', np.random.normal(40, 12, n),
                   np.where(zones == 'Suburban', np.random.normal(20, 6, n), np.random.normal(8, 3, n))),
    'O3': np.where(zones == 'Rural', np.random.normal(50, 10, n),
                  np.where(zones == 'Suburban', np.random.normal(40, 8, n), np.random.normal(30, 10, n))),
    'CO': np.random.normal(0.8, 0.3, n) + np.random.uniform(0, 0.5, n),
    'Zone': zones
}
df = pd.DataFrame(data)

plt.style.use('dark_background')
sns.set_style("darkgrid", {'axes.facecolor': '#0a0a0f', 'figure.facecolor': '#0a0a0f', 'grid.color': '#333333'})

palette = {'Urban': '#F54927', 'Suburban': '#F5B027', 'Rural': '#27F5B0'}

g = sns.pairplot(
    df,
    hue='Zone',
    palette=palette,
    height=2,
    kind='scatter',
    diag_kind='kde',
    markers=['o', 's', '^'],
    plot_kws={'alpha': 0.7, 's': 50, 'edgecolor': 'white', 'linewidths': 0.4},
    diag_kws={'alpha': 0.5, 'linewidth': 2.5, 'fill': True}
)

g.fig.set_facecolor('#0a0a0f')
for ax in g.axes.flat:
    if ax:
        ax.set_facecolor('#0a0a0f')
        for spine in ax.spines.values():
            spine.set_color('#333333')
        ax.tick_params(colors='#888888')
        ax.xaxis.label.set_color('white')
        ax.yaxis.label.set_color('white')

g.fig.suptitle('Air Quality Monitoring Network', fontsize=14, fontweight='bold', color='white', y=1.02)
plt.setp(g._legend.get_title(), color='white')
plt.setp(g._legend.get_texts(), color='white')

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support