3D Scatter

Brain fMRI Activation Map

Functional MRI brain activation showing regions of interest with varying activity levels.

Output
Brain fMRI Activation Map
Python
import matplotlib.pyplot as plt
import numpy as np

np.random.seed(789)

# Brain region activation points
n_points = 200

# Generate points within brain-shaped volume
theta = np.random.uniform(0, 2*np.pi, n_points)
phi = np.random.uniform(0, np.pi, n_points)
r = np.random.uniform(0.3, 1, n_points)

# Ellipsoid brain shape
x = r * 0.8 * np.sin(phi) * np.cos(theta)
y = r * 1.0 * np.sin(phi) * np.sin(theta)
z = r * 0.7 * np.cos(phi)

# Activation level (some regions more active)
activation = np.exp(-3 * ((x-0.3)**2 + (y-0.2)**2 + z**2))  # Visual cortex
activation += 0.5 * np.exp(-3 * ((x+0.3)**2 + y**2 + (z-0.3)**2))  # Motor
activation += np.random.exponential(0.1, n_points)
activation = activation / activation.max()

fig = plt.figure(figsize=(10, 8), facecolor='#0a0a0f')
ax = fig.add_subplot(111, projection='3d', facecolor='#0a0a0f')

scatter = ax.scatter(x, y, z, c=activation, cmap='hot', s=activation*100+20, 
                     alpha=0.7, edgecolors='none')

ax.set_xlabel('X (L-R)', color='white', fontsize=10)
ax.set_ylabel('Y (P-A)', color='white', fontsize=10)
ax.set_zlabel('Z (I-S)', color='white', fontsize=10)
ax.set_title('Brain fMRI Activation Map', color='white', fontsize=14, fontweight='bold', pad=20)

ax.tick_params(colors='#64748b', labelsize=8)
ax.xaxis.pane.fill = False
ax.yaxis.pane.fill = False
ax.zaxis.pane.fill = False
ax.xaxis.pane.set_edgecolor('#1e293b')
ax.yaxis.pane.set_edgecolor('#1e293b')
ax.zaxis.pane.set_edgecolor('#1e293b')

ax.view_init(elev=10, azim=60)
plt.tight_layout()
plt.show()
Library

Matplotlib

Category

3D Charts

Did this help you?

Support PyLucid to keep it free & growing

Support