In uitable
, I want to access the cell above the row labels and to the left of the column labels. I would like to put some text in that area. Can this be done?
The short answer is yes, but it's a bit of a pain. You can add a text uicontrol
and position it appropriately.
A functional example:
% Dummy figure and table
f = figure;
d = gallery('integerdata',100,[10 3],0);
t = uitable(f,'Data',d,'ColumnWidth',{50});
% Add text uicontrol and position appropriately
txt = uicontrol( ...
'Style', 'text', ...
'BackgroundColor', 'magenta', ...
'String', 'hi', ...
'Units', 'Pixels', ...
'Position', [21 300 32 19] ...
);
Which gives us the following:
That being said, this is not a very robust option and is a bit of a pain to position as necessary. There also is not a documented vertical alignment property for a text uicontrol
; you'll have to leverage the underlying Java to do so (or some other workaround).
Since the majority of MATLAB's graphics system is built in Java, it's very likely you could access the underlying Java here and modify the table more robustly. I'm not familiar with this approach so I can't speak to it at this time.