3D Fill Between

3D Galaxy Spiral Arms

Astronomical visualization of spiral galaxy arm structure with star density variation.

Output
3D Galaxy Spiral Arms
Python
import matplotlib.pyplot as plt
import numpy as np

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

n = 500
t = np.linspace(0, 4*np.pi, n)

# Spiral arms with slight vertical wave
r_outer = 0.5 + 0.4 * t
r_inner = 0.3 + 0.25 * t
z_wave = 0.15 * np.sin(t * 2)

# Two spiral arms
for arm_offset in [0, np.pi]:
    x_outer = r_outer * np.cos(t + arm_offset)
    y_outer = r_outer * np.sin(t + arm_offset)
    
    x_inner = r_inner * np.cos(t + arm_offset)
    y_inner = r_inner * np.sin(t + arm_offset)
    
    ax.plot(x_outer, y_outer, z_wave, linewidth=2, color='#F5B027')
    ax.plot(x_inner, y_inner, z_wave * 0.8, linewidth=1.5, color='#27D3F5')
    
    # Star field
    for i in range(0, n, 8):
        ax.plot([x_outer[i], x_inner[i]], [y_outer[i], y_inner[i]], 
                [z_wave[i], z_wave[i] * 0.8], 
                color='#6CF527', alpha=0.2, linewidth=0.5)

ax.set_xlabel('X', fontsize=11, color='white')
ax.set_ylabel('Y', fontsize=11, color='white')
ax.set_zlabel('Z', fontsize=11, color='white')
ax.set_title('Spiral Galaxy Arms', fontsize=14, color='white', fontweight='bold', pad=15)

ax.tick_params(colors='#888888', labelsize=9)
ax.xaxis.pane.fill = False
ax.yaxis.pane.fill = False
ax.zaxis.pane.fill = False
ax.xaxis.pane.set_edgecolor('#333333')
ax.yaxis.pane.set_edgecolor('#333333')
ax.zaxis.pane.set_edgecolor('#333333')
ax.grid(True, alpha=0.3, color='#555555')

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

3D Charts

Did this help you?

Support PyLucid to keep it free & growing

Support