這裏就是標記(文本+圓圈)是不變的縮放的示例/調整:
%# some graph in 2D
[adj,XY] = bucky;
N = 30;
adj = adj(1:N,1:N);
XY = XY(1:N,1:2);
%# plot edges
[xx yy] = gplot(adj, XY);
hFig = figure(); axis equal
line(xx, yy, 'LineStyle','-', 'Color','b', 'Marker','s', 'MarkerFaceColor','g')
%# draw text near vertices
xoff = 0; yoff = 0; %# optional offsets
str = strtrim(cellstr(num2str((1:N)')));
hTxt = text(XY(:,1)+xoff, XY(:,2)+yoff, str, ...
'FontSize',12, 'FontWeight','bold', ...
'HorizontalAlign','right', 'VerticalAlign','bottom');
%# draw circles around text
e = cell2mat(get(hTxt, {'Extent'}));
p = e(:,1:2) + e(:,3:4)./2;
hLine = line('XData',p(:,1), 'YData',p(:,2), ...
'LineStyle','none', 'Marker','o', 'MarkerSize',18, ...
'MarkerFaceColor','none', 'MarkerEdgeColor','k');
%# link circles position to text (on zoom and figure resize)
callbackFcn = @(o,e) set(hLine, ...
'XData',cellfun(@(x)x(1)+x(3)/2,get(hTxt,{'Extent'})), ...
'YData',cellfun(@(x)x(2)+x(4)/2,get(hTxt,{'Extent'})));
set(zoom(hFig), 'ActionPostCallback',callbackFcn)
set(hFig, 'ResizeFcn',callbackFcn)
![screenshot](https://i.stack.imgur.com/4pKKL.png)
比較針對@catchmeifyoutry建議(注意基於乳膠液後兩位數字):
%# use LaTeX to draw circled text at vertices
%#str = num2str((1:N)', '$\\textcircled{%d}$');
str = num2str((1:N)', '$\\raisebox{.5pt}{\\textcircled{\\raisebox{-.9pt} {%d}}}$');
text(XY(:,1), XY(:,2), str, ...
'HorizontalAlign','right', 'VerticalAlign','bottom', ...
'Interpreter','latex', 'FontSize',18)
![screenshot_latex](https://i.stack.imgur.com/DK1vS.png)
甜美!!!!!!!這真的有幫助。謝謝 - 我知道TeX中的一些基礎知識,但在過去的10年中一直沒有使用它。一旦我發現我的腦細胞太多以至於不熟悉我經常使用的工具,我就停止使用它。 :-( –
很高興幫助:) – catchmeifyoutry