3차원 그래프와 2차원 등고선
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
from matplotlib import cm
import numpy as np
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
x= np.arange(-100,100,1)
y= np.arange(-100,100,1)
X,Y=np.meshgrid(x,y)
Z=X**2-Y**2+Y
v=[100*i for i in range(100)]
cset1 = ax.contour(X, Y, Z,zdir='z',offset=10000,color='blue')
cset = ax.contour(X, Y, Z,v,cmap=cm.coolwarm,alpha=0.3)
ax.set_xlabel('X')
ax.set_xlim(-100, 100)
ax.set_ylabel('Y')
ax.set_ylim(-100, 100)
ax.set_zlabel('Z')
ax.set_zlim(0, 10000)
ax.clabel(cset1, fontsize=10, inline=1)
plt.show()
3차원 그래프에 등고선을 넣는 예제
Leave a Comment