How do I place a uitable in a subplot (MATLAB R2013a)?
41 views (last 30 days)
Show older comments
MathWorks Support Team
on 21 Nov 2016
Answered: MathWorks Support Team
on 21 Nov 2016
I would like to place a uitable so that it fits exactly into one of the subplots in my figure. Is there a way to associate a uitable with a subplot?
Accepted Answer
MathWorks Support Team
on 21 Nov 2016
There is no way to directly associate a uitable with a subplot, as uitable cannot be children of an axes. However, there is a simple workaround for this which involves saving the properties of the subplot.
The general idea is to create the subplot where you want the uitable to be located. Once the subplot is created, you can save the "Position" property of the subplot. This property contains both the location and the size of the axes. You can also save the units to ensure that the "Position" values are interpreted correctly.
Once these values are saved, you can delete the axes, and create a uitable using the same "Position" and "Unit" properties. This will ensure that the uitable has the same location and size as the subplot axes. For example, please try the following example code.
hf = figure;
ha = subplot(2,3,5);
pos = get(ha,'Position');
un = get(ha,'Units');
delete(ha)
ht = uitable('Units',un,'Position',pos)
This will create a uitable exactly where the subplot was first displayed.
0 Comments
More Answers (0)
See Also
Categories
Find more on Subplots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!