Create a point with a number inside

2 ビュー (過去 30 日間)
Hoang Vu Huy
Hoang Vu Huy 2023 年 2 月 23 日
コメント済み: Askic V 2023 年 2 月 23 日
I want to creat a fig:
How to creat a point with a number inside?

回答 (3 件)

Simon Chan
Simon Chan 2023 年 2 月 23 日
r = 5; % Radius of small circle
rho = 50; % Radius of big circle
Np = 16; % Number of circle
theta = linspace(pi,-pi,Np+1);
[x,y] = pol2cart(theta,rho); % coordinates of small circle center
t = linspace(0, 2*pi);
apoint = 1:Np; % Line connection, starting point
bpoint = circshift(1:16,-4); % Line coonection, end point
for w = 1:Np
line([x(apoint(w)) x(bpoint(w))],[y(apoint(w)) y(bpoint(w))],'Color','k'); % Draw lines first
end
rectangle('Position',[-rho -rho 2*rho 2*rho],'Curvature',[1 1])% % Draw big circle
for k = 1:Np
patch(x(k)+r*cos(t), y(k)+r*sin(t), 'w','FaceAlpha',1); % Draw small circle
end
text(x(1:Np),y(1:Np),string(1:Np),'HorizontalAlignment','center'); % Add the text
axis equal
axis off
  1 件のコメント
Askic V
Askic V 2023 年 2 月 23 日
What an elegant solution. Bravo Simon.

サインインしてコメントする。


Walter Roberson
Walter Roberson 2023 年 2 月 23 日
viscircles() and text()
Or possibly use a quite large 'o' marker, and text()
Or create patch objects with face color white. fill() could be used for that.

KSSV
KSSV 2023 年 2 月 23 日
th = linspace(0,2*pi) ;
x = cos(th) ;
y = sin(th) ;
% Make numbers
idx = 1:5:length(th) ;
figure
hold on
plot(x,y,'k','LineWidth',2)
scatter(x(idx),y(idx),300,'O','MarkerEdgeColor','k','MarkerFaceColor','w')
text(x(idx),y(idx),num2str(idx'))

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by