目录
1、代码
import numpy as np
import matplotlib.pyplot as plt
def normp(num:int,ntype:int):
delta = 2/(2*num)
points1=np.zeros((2*(2*num+1),2),dtype=np.float64)
points=np.zeros(((2*num+1),2),dtype=np.float64)
for i in range(2*num+1):
points[i,0] = -1.0+delta*i
#points[i+2*num+1,0] = -1+delta*i
points[i,1] = (1-(np.abs(-1+delta*i))**ntype)**(1./ntype)
#points[i+2*num+1,1] = -(1-(np.abs(-1+delta*i))**ntype)**(1./ntype)
points1[:2*num+1,0]=points[:,0]
points1[2*num+1:,0] =points[:,0]
#points1[:2*num+1,1]=points[:,1]
#points1[2*num+1:,1] =-1*points[:,1]
x=points[:,0]
y=points[:,1]
return [x,y]
def main():
fig=plt.figure()
num = 1024
axes=fig.add_subplot(221)
ntype =0.5
[x,y] = normp(num,ntype)
axes.plot(x,y,color='b')
axes.plot(x,-1*y,color='b')
axes=fig.add_subplot(222)
ntype =1
[x,y] = normp(num,ntype)
axes.plot(x,y,color='b')
axes.plot(x,-1*y,color='b')
axes=fig.add_subplot(223)
ntype =2
[x,y] = normp(num,ntype)
axes.plot(x,y,color='b')
axes.plot(x,-1*y,color='b')
axes=fig.add_subplot(224)
ntype =5
[x,y] = normp(num,ntype)
axes.plot(x,y,color='b')
axes.plot(x,-1*y,color='b')
axes.axis('equal')
plt.show()
if __name__ == '__main__':
main()
2、结果