plot title formatting with table

3 visualizaciones (últimos 30 días)
Kiran Karra
Kiran Karra el 22 de Ag. de 2016
Respondida: Tillmann el 26 de Sept. de 2018
I have a figure with many subplots, and each subplot has an associated "metric." Normally, you'd put the metric in the title of the figure ... but suppose I am trying to compare 5 different metrics for each subplot. Is there a nice way to display all 5 of them in the title without it looking too crowded?
I suppose one approach is something like this ...
but even this looks cumbersome, and I don't know if it is possible to put tables in titles in Matlab?
Any suggestions are greatly appreciated!
Cheers,

Respuestas (2)

Walter Roberson
Walter Roberson el 23 de Ag. de 2016
title() does permit 'Interpreter', 'latex' so you might be able to use the File Exchange contribution https://www.mathworks.com/matlabcentral/fileexchange/44274-latextable
However, I would not be surprised if it assumes does not get the spacing right between the title and the graph.

Tillmann
Tillmann el 26 de Sept. de 2018
I was just looking for the same and tried out the latextable option. For me it didn't work, because of the table environment. However if you directly use the tabular environment, it does work.
MWE:
tbl_header = "\begin{tabular}{ccccc} \textbf{DoE ID} & \multicolumn{2}{c}{\textbf{Toolposition} (in mm)} & \multicolumn{2}{c}{\textbf{Material}} \\ & x & y & name & thickness (in mm) \\ \hline";
tbl_footer = "\end{tabular}";
for ii = 1:5
plot((1:256)', rand(256,1)); hold on;
tbl_body(ii) = sprintf("%d & %.2f & %.2f & %s & %.2f", randi(10,1), rand, rand, 'random string', randi(10,1));
end
tbl_str = sprintf("%s %s %s", tbl_header, strjoin(tbl_body, ' \\\\ '), tbl_footer);
title(...
{...
sprintf("\\textbf{Machine:} %s", 'Random machine name'), ...
"", ...
tbl_str ...
}, ...
'Interpreter','latex' ...
);

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by