import matplotlib.pyplot as plt
import numpy as np
x=np.linspace(0,10,100)
y=np.linspace(0,10,100)
X,Y=np.meshgrid(x,y)
Z=np.sin(X)*np.cos(Y)
fig=plt.figure(figsize=(8,6))
ax=fig.add_subplot(111,projection='3d')
ax.plot_surface(X,Y,Z,cmap='plasma',edgecolor='k',linewidth=0.3)
ax.set_title("3D Folded Origami Pattern ")
plt.show()
#source code --> clcoding.com
Code Explanation:
1. Importing Libraries
import numpy as np
import matplotlib.pyplot as plt
numpy (as np): Used for numerical operations and
array handling.
x = np.linspace(0, 10, 100)
y = np.linspace(0, 10, 100)
X, Y = np.meshgrid(x, y)
np.linspace(0, 10, 100): Creates 100 values linearly
spaced from 0 to 10 for both x and y axes.
Z = np.sin(X) * np.cos(Y)
This creates a wave-like height map:
fig = plt.figure(figsize=(10, 6))
ax = fig.add_subplot(111, projection='3d')
Creates a figure (fig) with a specific size (10 by 6
inches).
ax.plot_surface(X, Y, Z, cmap='plasma',
edgecolor='k', linewidth=0.3)
plot_surface: Draws a 3D surface plot.
ax.set_title("3D Folded Origami Pattern
(Miura-inspired)")
plt.show()
Adds a title to the plot.
0 Comments:
Post a Comment