3D Fill Between

Twisted Ribbon Surface

3D twisted ribbon with gradient fill using neon purple and pink

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

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

# Twisted ribbon parameters
n = 100
theta = np.linspace(0, 3*np.pi, n)
width = 0.3

x1 = (1 + width*np.cos(theta/2)) * np.cos(theta)
y1 = (1 + width*np.cos(theta/2)) * np.sin(theta)
z1 = width * np.sin(theta/2) + np.linspace(0, 2, n)

x2 = (1 - width*np.cos(theta/2)) * np.cos(theta)
y2 = (1 - width*np.cos(theta/2)) * np.sin(theta)
z2 = -width * np.sin(theta/2) + np.linspace(0, 2, n)

ax.plot(x1, y1, z1, linewidth=2.5, color='#5314E6')
ax.plot(x2, y2, z2, linewidth=2.5, color='#F527B0')

# Fill between with connecting lines
for i in range(0, n, 2):
    ax.plot([x1[i], x2[i]], [y1[i], y2[i]], [z1[i], z2[i]], 
            color='#F5D327', alpha=0.3, linewidth=0.8)

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('Twisted Ribbon Surface', fontsize=14, color='#1f2937', fontweight='bold', pad=15)

ax.xaxis.pane.fill = False
ax.yaxis.pane.fill = False
ax.zaxis.pane.fill = False
ax.xaxis.pane.set_edgecolor('#000000')
ax.yaxis.pane.set_edgecolor('#000000')
ax.zaxis.pane.set_edgecolor('#000000')
ax.tick_params(colors='#000000', labelsize=9)
ax.grid(True, alpha=0.5, linewidth=0.5)
ax.xaxis._axinfo['grid']['color'] = '#000000'
ax.yaxis._axinfo['grid']['color'] = '#000000'
ax.zaxis._axinfo['grid']['color'] = '#000000'

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

Matplotlib

Category

3D Charts

Did this help you?

Support PyLucid to keep it free & growing

Support