Add a box with error metrics in plot
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Daphne PARLIARI
el 13 de Feb. de 2020
Comentada: Daphne PARLIARI
el 27 de Feb. de 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 comentarios
Respuesta aceptada
Rik
el 13 de Feb. de 2020
Editada: Rik
el 13 de Feb. de 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 comentarios
Rik
el 26 de Feb. de 2020
If you know the order in which the parameters appear you can select them by modifying the for loop.
Más respuestas (0)
Ver también
Categorías
Más información sobre Annotations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!