Increase text size in Matlab graph

9 ビュー (過去 30 日間)
Anjali
Anjali 2016 年 9 月 18 日
コメント済み: Star Strider 2016 年 9 月 20 日
Hi!
I am using Matlab graph function to plot an adjacency matrix. However, the node labels in the graph are very small. Could somebody please tell me a way to increase the text font size? (The usual font increasing options such as
set(gca,'fontsize',18)
does not work for the graph function) . Thanks.

採用された回答

Star Strider
Star Strider 2016 年 9 月 19 日
I’m not exactly certain what you want. I modified this example from the graph documentation to change the font size of the node labels:
s = [1 1 1 2 2 3 3 4 5 5 6 7]; % Begin Original Documentation Example
t = [2 4 8 3 7 4 6 5 6 8 7 8];
weights = [10 10 1 10 1 10 1 1 12 12 12 12];
names = {'A' 'B' 'C' 'D' 'E' 'F' 'G' 'H'};
G = graph(s,t,weights,names);
figure(1)
h = plot(G,'EdgeLabel',G.Edges.Weight); % End Original Documentation Example
nl = h.NodeLabel;
h.NodeLabel = '';
xd = get(h, 'XData');
yd = get(h, 'YData');
text(xd, yd, nl, 'FontSize',18, 'FontWeight','bold', 'HorizontalAlignment','left', 'VerticalAlignment','middle')
  2 件のコメント
Anjali
Anjali 2016 年 9 月 20 日
Thank you very much. This is exactly what I needed.
Star Strider
Star Strider 2016 年 9 月 20 日
My pleasure.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by