Increase text size in Matlab graph

9 views (last 30 days)
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.

Accepted Answer

Star Strider
Star Strider on 19 Sep 2016
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 Comments
Anjali
Anjali on 20 Sep 2016
Thank you very much. This is exactly what I needed.

Sign in to comment.

More Answers (0)

Categories

Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!