25 lines
513 B
Python
25 lines
513 B
Python
import matplotlib.pyplot as plt
|
|
|
|
import numpy as np
|
|
|
|
def f(x):
|
|
return 4*np.sin(x)
|
|
|
|
def g(x):
|
|
return x**2
|
|
|
|
def plot_3d_surface():
|
|
fig = plt.figure()
|
|
ax = fig.add_subplot(111, projection='3d')
|
|
x = np.linspace(-5, 5, 100)
|
|
y = np.linspace(-5, 5, 100)
|
|
X, Y = np.meshgrid(x, y)
|
|
Z = f(X) + g(Y)
|
|
ax.plot_surface(X, Y, Z, cmap='viridis')
|
|
ax.set_xlabel('X-axis')
|
|
ax.set_ylabel('Y-axis')
|
|
ax.set_zlabel('Z-axis')
|
|
plt.show()
|
|
if __name__ == "__main__":
|
|
plot_3d_surface()
|