plot title formatting with table
3 次查看(过去 30 天)
显示 更早的评论
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,
0 个评论
回答(2 个)
Walter Roberson
2016-8-23
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.
0 个评论
Tillmann
2018-9-26
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' ...
);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Title 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!