Add text to data points in a circle plot
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Juan David Mateus
am 4 Mai 2020
Kommentiert: Juan David Mateus
am 4 Mai 2020
Hello,
I have a 26x26 matrix called mdist of distances of 26 banks with themselves which i plot like this:
figure;
x=graph(mdist);
plot(x,'layout','circle');
The thing is that i need to put the names of each bank in the data points so it looks like the following(mine does not have those names)

2 Kommentare
Akzeptierte Antwort
Ameer Hamza
am 4 Mai 2020
Bearbeitet: Ameer Hamza
am 4 Mai 2020
If you get the handle of GraphPlot
p = plot(G,'layout','circle');
Then you can get the x and y location of each node using
X = p.XData
Y = p.YData
However, If you want to add text at an arbitrary point, then you can make the xtick values visible and then use text() to add the text at the location you want
figure;
ax = axes();
A = randi([1 10], 50);
G = graph(A,'upper');
p = plot(G,'layout','circle');
ax.XAxis.TickValuesMode = 'auto';
ax.YAxis.TickValuesMode = 'auto';
text(0, 0.5, 'myText', 'FontSize', 14, 'Color', 'r')

And then you can again make them invisible using
ax.XAxis.TickValues = []
ax.YAxis.TickValues = []
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!