#!/usr/bin/env python
# coding: utf-8
# # Three-Dimensional contour plots
# In[15]:
import numpy as np
import matplotlib.pyplot as plt
def f(x, y):
return np.sin(np.sqrt(x ** 2 + y ** 2))
x = np.linspace(-6, 6, 30)
y = np.linspace(-6, 6, 30)
x, y = np.meshgrid(x, y)
z = f(x, y) #clcoding.com
fig = plt.figure()
ax = plt.axes(projection='3d')
ax.contour3D(x,y,z,50, cmap='binary')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
plt.show()
fig = plt.figure()
ax = plt.axes(projection='3d')
ax.plot_wireframe(x,y,z, color='black')
ax.set_title('wireframe')
plt.show()
ax = plt.axes(projection='3d')
ax.plot_surface(x, y, z, rstride=1,
cstride=1, cmap='viridis',
edgecolor='none')
ax.set_title('surface')
plt.show()
# In[ ]:
0 Comments:
Post a Comment