Faceted Scatter Plot

Marine Species Richness by Zone

Species richness patterns across marine environments

Output
Marine Species Richness by Zone
Python
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np

np.random.seed(2222)

zones = ['Epipelagic', 'Mesopelagic', 'Bathypelagic', 'Abyssal']
data = []
for zone in zones:
    n = 40
    temperature = np.random.uniform(2, 25, n)
    diversity_base = {'Epipelagic': 3.5, 'Mesopelagic': 2.2, 'Bathypelagic': 1.5, 'Abyssal': 0.8}
    diversity = diversity_base[zone] * np.log(temperature + 5) + np.random.normal(0, 0.4, n)
    for t, d in zip(temperature, diversity):
        data.append({'Temperature (°C)': t, 'Shannon Index': d, 'Depth Zone': zone})

df = pd.DataFrame(data)

sns.set_style("whitegrid", {
    'axes.facecolor': '#ffffff',
    'figure.facecolor': '#ffffff',
    'grid.color': '#eeeeee'
})

palette = ['#27D3F5', '#276CF5', '#4927F5', '#5314E6']

g = sns.lmplot(
    data=df,
    x='Temperature (°C)',
    y='Shannon Index',
    hue='Depth Zone',
    col='Depth Zone',
    col_wrap=2,
    height=3.5,
    aspect=1.2,
    palette=palette,
    scatter_kws={'alpha': 0.7, 's': 55, 'edgecolor': 'white', 'linewidths': 0.6},
    line_kws={'linewidth': 2.5},
    ci=95
)

g.fig.set_facecolor('#ffffff')
for ax in g.axes.flat:
    ax.set_facecolor('#ffffff')
    for spine in ax.spines.values():
        spine.set_color('#dddddd')

g.fig.suptitle('Marine Biodiversity Gradients', fontsize=14, fontweight='bold', color='#1a1a1a', y=1.02)
plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Pairwise Data

Did this help you?

Support PyLucid to keep it free & growing

Support