Add a box with error metrics in plot
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Daphne PARLIARI
am 13 Feb. 2020
Kommentiert: Daphne PARLIARI
am 27 Feb. 2020
Hello everyone.
I have a plot generated by Matlab to which I want to add a box containing some error metrics I produced by my own (please see attached).
These statistics are *not* the ones from Tools -> Data statistics. Is there a way to achieve that?
Thanks in advance!
0 Kommentare
Akzeptierte Antwort
Rik
am 13 Feb. 2020
Bearbeitet: Rik
am 13 Feb. 2020
You can add information to a plot with an annotation, or you can use the rectangle and text functions. The code below will read your data and adapt the example in the documentation.
file='Daily_Stats_Automn2015 Airport Temperature .csv';
%read the whole file, split at the newline, then split at the comma
headers=fileread(file);
headers=split(headers,newline);
headers=split(headers{1},',');
%read the data
data=readmatrix(file,'NumHeaderLines',1);
%format data and text to a cell array
txt=cell(numel(headers),1);
for n=1:numel(txt)
txt{n}=sprintf('%s = %.4f',headers{n},data(n));
end
figure(1),clf(1)
plot(0:10,0:10)
x = [0.35 0.5];
y = [0.6 0.5];
annotation('textarrow',x,y,'String',txt);
5 Kommentare
Rik
am 26 Feb. 2020
If you know the order in which the parameters appear you can select them by modifying the for loop.
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!