3D Surface
Cassini Oval Surface
3D surface derived from Cassini oval curves - planetary orbit-like shape in amber-yellow gradient.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.colors import LinearSegmentedColormap
# Cassini-like surface
a = 1.1
c = 1.0
u = np.linspace(0, 2*np.pi, 100)
v = np.linspace(0, 2*np.pi, 100)
u, v = np.meshgrid(u, v)
# Modified Cassini parametrization
r2 = a**4 + c**4 - 2*a**2*c**2*np.cos(2*u)
r = np.sqrt(np.sqrt(np.maximum(r2, 0)))
x = r * np.cos(u) * (1 + 0.2*np.sin(v))
y = r * np.sin(u) * (1 + 0.2*np.sin(v))
z = 0.5 * np.cos(v)
# Custom colormap
colors = ['#ffffff', '#fef3c7', '#F5B027', '#D3F527', '#fef08a']
cmap = LinearSegmentedColormap.from_list('amber_yellow', colors, N=256)
fig = plt.figure(figsize=(10, 8), facecolor='#ffffff')
ax = fig.add_subplot(111, projection='3d', facecolor='#ffffff')
surf = ax.plot_surface(x, y, z, cmap=cmap, alpha=0.85, linewidth=0.1, edgecolor='#33333318')
ax.set_xlabel('X', fontsize=10, color='#374151', labelpad=10)
ax.set_ylabel('Y', fontsize=10, color='#374151', labelpad=10)
ax.set_zlabel('Z', fontsize=10, color='#374151', labelpad=10)
ax.set_title("Cassini Oval Surface", fontsize=14, color='#1f2937', 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.view_init(elev=30, azim=45)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
3D Charts
More 3D Surface examples
☕