3D Fill Between
Spherical Loxodrome
3D loxodrome spiral on sphere with blue and mint neon
Output
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')
# Loxodrome parameters
n = 400
t = np.linspace(-12, 12, n)
a = 0.18
theta = t
phi = 2 * np.arctan(np.exp(a * t)) - np.pi/2
x1 = np.cos(phi) * np.cos(theta)
y1 = np.cos(phi) * np.sin(theta)
z1 = np.sin(phi)
# Second spiral with offset
x2 = np.cos(phi) * np.cos(theta + 0.25)
y2 = np.cos(phi) * np.sin(theta + 0.25)
z2 = np.sin(phi) * 0.92
ax.plot(x1, y1, z1, linewidth=2, color='#276CF5')
ax.plot(x2, y2, z2, linewidth=2, color='#27F5B0')
# Connect spirals
for i in range(0, n, 8):
ax.plot([x1[i], x2[i]], [y1[i], y2[i]], [z1[i], z2[i]],
color='#F5B027', alpha=0.25, linewidth=0.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('Spherical Loxodrome', 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=20, azim=45)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
3D Charts
More 3D Fill Between examples
☕