3D Line

Twisted Ribbon Helix

A twisted ribbon following a helical path, showing the edges and surface connections in red tones.

Output
Twisted Ribbon Helix
Python
import matplotlib.pyplot as plt
import numpy as np

# Twisted ribbon effect with two parallel curves
n = 400
t = np.linspace(0, 4 * np.pi, n)

# Main curve
x1 = np.cos(t)
y1 = np.sin(t)
z1 = t / (2 * np.pi)

# Offset for ribbon width (rotates around main curve)
width = 0.15
x2 = np.cos(t) * (1 + width * np.cos(3 * t))
y2 = np.sin(t) * (1 + width * np.cos(3 * t))
z2 = t / (2 * np.pi) + width * np.sin(3 * t)

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

# Two edges of ribbon
ax.plot(x1, y1, z1, color='#dc2626', linewidth=2)
ax.plot(x2, y2, z2, color='#f87171', linewidth=2)

# Connect edges periodically
for i in range(0, n, 20):
    ax.plot([x1[i], x2[i]], [y1[i], y2[i]], [z1[i], z2[i]], 
            color='#fca5a5', linewidth=0.8, alpha=0.5)

ax.set_xlim(-1.5, 1.5)
ax.set_ylim(-1.5, 1.5)
ax.set_zlim(0, 2.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('Twisted Ribbon Helix', 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.grid(True, alpha=0.3, color='#d1d5db')

ax.view_init(elev=25, azim=35)
plt.tight_layout()
plt.show()
Library

Matplotlib

Category

3D Charts

Did this help you?

Support PyLucid to keep it free & growing

Support