title to a table
20 次查看(过去 30 天)
显示 更早的评论
Hi, I know my question is stupid, but i don't know really well the Matlab function relating to table and graphs and I cannot find it. I need to put title to the table I built using uitable. I tried with title('Title') but it also draw an empty graph under the table and it's not very nice.
may someone help me? Thanks Gaia
0 个评论
采纳的回答
Paulo Silva
2011-7-3
uitables don't have titles, what you can do is put one static text box above your uitable.
0 个评论
更多回答(2 个)
Oleg Komarov
2011-7-2
After you created the uitable (or when declaring the figure):
set(cgf,'Name','myName')
set(gcf,'Name','myName','NumberTitle','off') % To keep only your title.
Matthew Nann
2019-11-3
编辑:Matthew Nann
2019-11-3
%% nested function:
function createTable(data, titleName)
%creating only one figure for both simulations
if graph == 1
f = figure(2);
end
f = figure(2);
%creating a subplot to add a title then remove the axis's labels
subplot(2,1,graph)
set(gca,'YTickLabel',[]);
set(gca,'XTickLabel',[]);
title(titleName);
rnames = {};
cnames = {};
tableData = [];
%creating table to place over plot containing the bounces and peaks data
t = uitable(f,'Data',tableData,...
'ColumnName',cnames,...
'RowName',rnames,...
'ColumnWidth',{100});
pos = get(subplot(2,1,graph),'position');
set(t,'units','normalized')
set(t,'position',pos)
end
I used this function to create a table in one of my assignments. Create a plot add the title and remove the axis ticks and labels, then get the position of the plot and add in the uitable. The uitable will be essentially on top of the plot but the title will remain.
2 个评论
Deming Zhang
2023-3-13
Thanks for sharing this idea. I had costed lots of time to try to find a way to add a title to a table, but not got satisfied methods.
I hope Matlab can provide an easy way to add a title to a table, acctually, just add a title property to a table for plotting out. For wrting essay or documentation of batch data processing, people otfen need to print out tables with proper titles automatically. It is worth for Matlab to provide this function or ability.
Deming Zhang
2023-3-13
编辑:Deming Zhang
2023-3-13
Thanks for sharing this idea. I had costed lots of time to try to find a way to add a title to a table, but not got satisfied methods.
I hope Matlab can provide an easy way to add a title to an uitable, acctually, just add a title property to a table for plotting out. For wrting essay or documentation of batch data processing, people often need to print out uitables with proper titles automatically. It is worth for Matlab to provide this function or ability.
I might use uifigure() instead of figure() function, but it looks in uifigure() there is no easy way to copy the figure into your document. With figure() it is very easy to use the build-in menu "Copy Figure" and paste it to your document.
So, I also hope Matlab may provide the menu bar in uifigure() for people to easily copy the figure. The user may have their freedom to choose to disable/enable the menu bar.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!