import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
def petal_shape(k, theta):
return np.sin(k * theta)
k_values = np.linspace(2, 7, 20)
theta = np.linspace(0, 2 * np.pi, 400)
theta_grid, k_grid = np.meshgrid(theta, k_values)
r = petal_shape(k_grid, theta_grid)
x = r * np.cos(theta_grid)
y = r * np.sin(theta_grid)
z = k_grid
fig = plt.figure(figsize=(6, 6))
ax = fig.add_subplot(111, projection='3d')
ax.set_facecolor('black')
surface = ax.plot_surface(x, y, z, cmap='spring', edgecolor='none', alpha=0.95)
ax.set_title("Petal Swirl Matrix", color='white', fontsize=18)
ax.axis('off')
fig.colorbar(surface, shrink=0.5, aspect=10)
ax.view_init(elev=45, azim=135)
plt.show()
#source code --> clcoding.com


0 Comments:
Post a Comment