Centering data in uitable without using uifigure?

2 vues (au cours des 30 derniers jours)
Jordan Luke
Jordan Luke le 6 Sep 2023
Réponse apportée : Sachin le 11 Sep 2023
I need to center the data in my table without using the uifigure function as I am placing the uitable and a plot on the same figure using subplots and then later outputting to a pdf.
Any help appreciated!
Data = cellstr(string([xPosRound yPosRound jbChngRound jbDistBtwnRound]));
format default
m = 6;
figure
hAx=subplot(m,m,[7 8 9 13 14 15 19 20 21 25 25 27 31 32 33]);
hUI=uitable('Data',Data, ...
'ColumnName',["X" "Y" "Chainage" "Distance"],...
'RowName',row_array', ...
'Units', ...
'Normalized', ...
'Position',hAx.Position); axis off
hAy=subplot(m,m,[10 11 12 16 17 18 22 23 24 28 29 30 34 35 36]);
plot(xPos,yPos,'bo',x,y,'r'); axis padded equal
hAz = subplot(m,m,[3 4]);
imshow('mwp.jpg')
set(gcf, 'Position',[100 500 1040 800])

Réponses (1)

Sachin
Sachin le 11 Sep 2023
Hi Jordan,
I understand that you want to centrethe data in the table without using the ‘uifigure’ function.
There are some limitations when using 'figure'. I suggest you to use 'uifigure' to work with your workflow. A possible workaround that might be helpful to you when using the ‘uifigure’:
  1. Use the ‘uifigure’ and ‘uitable’ to add the table.
  2. After creating the table use ‘uistyle’ to center the data entries. Refer the following MATLAB Answer : https://in.mathworks.com/matlabcentral/answers/488135-how-to-change-horizontal-alignment-left-right-center-of-entries-in-a-uitable
  3. To add the ‘subplot’ in the ‘uifigure’, refer to the following MATLAB Answer - https://in.mathworks.com/matlabcentral/answers/1852898-how-to-use-subplot-in-a-uifigure
  4. If you want to save the figure, refer this MATLAB Answer - https://in.mathworks.com/matlabcentral/answers/406897-how-to-save-uitable-uifigure-into-pdf-file
I hope these suggestions helps in resolving the issues you are facing.
Thanks
Sachin

Catégories

En savoir plus sur Develop uifigure-Based Apps dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by