5x4 colored circle in a grid format
显示 更早的评论
Hello,
How do I create a 5x4 circles in a grid formate with specific circles having different colors
回答(1 个)
KSSV
2021-7-7
th = linspace(0,2*pi) ;
r = 0.1 ;
xc = r*cos(th) ;
yc = r*sin(th) ;
x = 1:5 ;
y = 1:4 ;
[X,Y] = meshgrid(x,y) ;
figure
hold on
for i = 1:4
for j = 1:5
patch(X(i,j)+xc,Y(i,j)+yc,rand(1,3))
end
end
Or
th = linspace(0,2*pi) ;
r = 0.1 ;
xc = r*cos(th) ;
yc = r*sin(th) ;
x = 1:5 ;
y = 1:4 ;
[X,Y] = meshgrid(x,y) ;
c = sqrt(X.^2+Y.^2) ;
scatter(X(:),Y(:),100,c(:),'filled')
类别
在 帮助中心 和 File Exchange 中查找有关 2-D and 3-D Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!