时间:2021-07-01 10:21:17 帮助过:15人阅读
t = (0:.02:2)*pi;
r = 0:.02:1;
pcolor(cos(t)'*r,sin(t)'*r,t'*(r==r))
colormap(hsv(256)), shading interp, axis image off
...被抢先了...# -*- coding:utf-8 -*-
from pylab import *
center = (250, 250)
radius = 250
img = zeros((500,500))
for i in range(500):
for j in range(500):
x = i - center[0] * 1.0
y = j - center[1] * 1.0
if x**2+y**2 < radius**2:
if x > 0:
img[i,j] = arctan(y/x)
elif x<0 and y>=0:
img[i,j] = arctan(y/x) + pi
elif x<0 and y<0:
img[i,j] = arctan(y/x) - pi
elif x==0 and y>0:
img[i,j] = pi / 2
elif x==0 and y<0:
img[i,j] = pi / -2
elif x==0 and y==0:
img[i,j] = 0.0
print img
imshow(img, cmap=cm.hsv)
show()
改编自@冯昱尧的代码from pylab import *
n=300
img=[[arctan2(x,y) if x*x+y*y<n*n else 0 for y in range(-n,n)] for x in range(-n,n)]
imshow(img, cmap=cm.hsv)
show()
如果根据这幅图,“光盘”的意思就是每一条半径的颜色在色相Hue上渐变。n=300;
c=Hue[i/n];
Graphics@Table[{c,EdgeForm@c,Disk[{0,0},1,2Pi/n{i-1,i}]},{i,n}]
期待mma的代码,估计一条语句搞定