塗りつぶしの円を描く​にはどうすればよいの​でしょうか

33 vues (au cours des 30 derniers jours)
Hiroshi Takase
Hiroshi Takase le 18 Nov 2020
Commenté : Hiroshi Takase le 22 Nov 2020
円をプロットすることはできたのですが、書いた円を塗りつぶしたものを作製するにはどうすればよいのでしょうか、
に記載のある
figure
colors = {'b','r','g','y','k'};
for k = 1:5
% Create 5 random circles to display,
X = rand(5,1);
Y = rand(5,1);
centers = [X Y];
radii = 0.1*rand(5,1);
% Clear the axes.
cla
% Fix the axis limits.
xlim([-0.1 1.1])
ylim([-0.1 1.1])
% Set the axis aspect ratio to 1:1.
axis square
% Set a title.
title(['k = ' num2str(k)])
% Display the circles.
viscircles(centers,radii,'Color',colors{k});
% Pause for 1 second.
pause(1)
で表示されるような1つのプロットに複数の円を中塗りで作製したいのですがどのようにすればよいのでしょうか。

Réponse acceptée

Akira Agata
Akira Agata le 20 Nov 2020
rectangle 関数の Curvature プロパティを [1 1] に設定する方法で円を描画するのはいかがでしょうか?
colors = {'b','r','g','y','k'};
X = rand(5,1);
Y = rand(5,1);
radii = 0.1*rand(5,1);
figure
for kk = 1:5
xCorner = X(kk) - radii(kk);
yCorner = Y(kk) - radii(kk);
rectangle(...
'Position', [xCorner, yCorner, radii(kk)*2, radii(kk)*2],...
'Curvature',[1 1],...
'FaceColor',colors{kk})
end
axis equal
box on
  1 commentaire
Hiroshi Takase
Hiroshi Takase le 22 Nov 2020
回答ありがとうございます。rectangleは四角だけと思っていましたので、意外でした参考にさせていただきます。

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur グラフィックス オブジェクトのプロパティ dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!