3D Scatter
Protein Alpha Helix Structure
3D visualization of protein structure showing alpha helix backbone with side chain atoms.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
np.random.seed(123)
# Simulate protein backbone with side chains
n_residues = 50
t = np.linspace(0, 4*np.pi, n_residues)
# Alpha helix backbone
x_backbone = np.cos(t) * 2
y_backbone = np.sin(t) * 2
z_backbone = t / np.pi
# Add side chain atoms
n_atoms = 200
x_atoms = []
y_atoms = []
z_atoms = []
colors = []
for i in range(n_residues):
n_side = np.random.randint(2, 6)
for j in range(n_side):
offset = np.random.uniform(0.5, 1.5)
angle = np.random.uniform(0, 2*np.pi)
x_atoms.append(x_backbone[i] + offset * np.cos(angle))
y_atoms.append(y_backbone[i] + offset * np.sin(angle))
z_atoms.append(z_backbone[i] + np.random.uniform(-0.3, 0.3))
colors.append(i)
fig = plt.figure(figsize=(10, 8), facecolor='#ffffff')
ax = fig.add_subplot(111, projection='3d', facecolor='#ffffff')
# Backbone
ax.plot(x_backbone, y_backbone, z_backbone, color='#1e40af', linewidth=2, alpha=0.8)
# Atoms
scatter = ax.scatter(x_atoms, y_atoms, z_atoms, c=colors, cmap='viridis',
s=40, alpha=0.7, edgecolors='white', linewidths=0.5)
ax.set_xlabel('X (Å)', color='#1f2937', fontsize=10)
ax.set_ylabel('Y (Å)', color='#1f2937', fontsize=10)
ax.set_zlabel('Z (Å)', color='#1f2937', fontsize=10)
ax.set_title('Protein Alpha Helix Structure', color='#1f2937', fontsize=14, fontweight='bold', pad=20)
ax.tick_params(colors='#6b7280', labelsize=8)
ax.xaxis.pane.fill = False
ax.yaxis.pane.fill = False
ax.zaxis.pane.fill = False
ax.xaxis.pane.set_edgecolor('#e5e7eb')
ax.yaxis.pane.set_edgecolor('#e5e7eb')
ax.zaxis.pane.set_edgecolor('#e5e7eb')
ax.view_init(elev=25, azim=45)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
3D Charts
☕