3D Fill Between

3D DNA Double Helix Structure

Molecular visualization of DNA double helix with base pair connections.

Output
3D DNA Double Helix Structure
Python
import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure(figsize=(12, 9), facecolor='#ffffff')
ax = fig.add_subplot(111, projection='3d')
ax.set_facecolor('#ffffff')

t = np.linspace(0, 6*np.pi, 300)
z = np.linspace(0, 10, 300)

# Double helix strands
helix1_x = np.cos(t)
helix1_y = np.sin(t)

helix2_x = np.cos(t + np.pi)
helix2_y = np.sin(t + np.pi)

# Plot strands
ax.plot(helix1_x, helix1_y, z, linewidth=3, color='#3B82F6')
ax.plot(helix2_x, helix2_y, z, linewidth=3, color='#EF4444')

# Base pair connections
for i in range(0, len(t), 8):
    ax.plot([helix1_x[i], helix2_x[i]], [helix1_y[i], helix2_y[i]], [z[i], z[i]], 
            color='#10B981', alpha=0.6, linewidth=1.5)

ax.set_xlabel('X', fontsize=11, color='#1f2937')
ax.set_ylabel('Y', fontsize=11, color='#1f2937')
ax.set_zlabel('Z', fontsize=11, color='#1f2937')
ax.set_title('DNA Double Helix', fontsize=14, color='#1f2937', fontweight='bold', pad=15)

ax.tick_params(colors='#374151', labelsize=9)
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.grid(True, alpha=0.3, color='#d1d5db')

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

3D Charts

Did this help you?

Support PyLucid to keep it free & growing

Support