首页 > 编程语言 >PYTHON画三维图

PYTHON画三维图

时间:2023-01-11 16:36:06浏览次数:39  
标签:plt PYTHON 三维图 color set lis ax Z1

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np

#bbb=[1 if (i <=0.5 or i >=1.5) else 0 for i in D

def fun(x, y):
value= x**2+y**2


return value

fig1 = plt.figure()
ax = Axes3D(fig1)
X, Y = np.mgrid[-4:4:40j, -4:4:40j]
Z1 = fun(X, Y)
numsize=len(Z1)
Z=Z1
for i in range(40):
for j in range(40):
if (Z1[i][j]<0.5 ):
Z[i][j]=1
elif (Z1[i][j]>11):
Z[i][j]=1
else:
Z[i][j]=0
# for i in range(len(Z1)):
# if lis[i] in str:
# lis[i]='-'
# print(lis)



# Z=[1 if (i <=10 or i >=20) else 0 for i in Z1]

# plt.title("This is main title")
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=plt.cm.coolwarm, alpha=0.5)
ax.set_xlabel('u', color='b')
ax.set_ylabel('v', color='r')
ax.set_zlabel('H(u,v)', color='g')
plt.show()

标签:plt,PYTHON,三维图,color,set,lis,ax,Z1
From: https://www.cnblogs.com/kn-zheng/p/17044173.html

相关文章