MATLAB: Increase text size in Matlab graph

graphincrease font sizeplot adjacency matrix

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.

Best Answer

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')