3D Stem

Neural Spike Train Recording

Neuroscience visualization of action potentials across multiple neurons over time.

Output
Neural Spike Train Recording
Python
import matplotlib.pyplot as plt
import numpy as np

np.random.seed(321)

# Neural spike train data
n_neurons = 5
n_spikes = 40

neuron_id = np.random.randint(0, n_neurons, n_spikes)
spike_time = np.sort(np.random.uniform(0, 1000, n_spikes))  # ms
amplitude = np.random.uniform(0.5, 1.5, n_spikes)

# Normalize
x = spike_time / 1000
y = neuron_id / n_neurons
z = amplitude

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

markerline, stemlines, baseline = ax.stem(x, y, z, linefmt='-', markerfmt='o', basefmt=' ')
plt.setp(stemlines, color='#22c55e', linewidth=1.2, alpha=0.7)
plt.setp(markerline, color='#4ade80', markersize=6)

ax.set_xlabel('Time (s)', color='white', fontsize=10)
ax.set_ylabel('Neuron ID', color='white', fontsize=10)
ax.set_zlabel('Amplitude (mV)', color='white', fontsize=10)
ax.set_title('Neural Spike Train Recording', 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=20, azim=35)
plt.tight_layout()
plt.show()
Library

Matplotlib

Category

3D Charts

Did this help you?

Support PyLucid to keep it free & growing

Support