Multiple Row Xlabels in Matlab App Designer UIFigure UIAxes
Show older comments
Hi there,
I am trying to figure out the simplest/cleanest way to place multiple row (in my case - two rows) xlabels into a UIFigure in Matlab App Designer.
Thanks!
Answers (1)
fig = figure;
app.UIAxes = uiaxes(fig);
You can place the following line in the startup function of your app.
xlabel(app.UIAxes,{'xlabel 1';'xlabel 2'})
6 Comments
Gillian Weir
on 24 Mar 2023
Be sure to upvote his Answer in the link above if this helps.
row1 = {'White' 'Green' 'Red' 'White' 'Green' 'Red'};
row2 = {'East' 'East' 'East' 'West' 'West' 'West'};
row3 = 10.5:15.5;
labelArray = [row1; row2; compose('%.1f',row3)];
tickLabels = strtrim(sprintf('%s\\newline%s\\newline%s\n', labelArray{:}));
fig = figure;
app.UIAxes = uiaxes(fig);
app.UIAxes.XTick = 1:6;
app.UIAxes.XLim = [0,7];
app.UIAxes.XTickLabel = tickLabels;
xlabel(app.UIAxes,{'Color';'Direction';'Value'})
Gillian Weir
on 24 Mar 2023
Kevin Holly
on 24 Mar 2023
I tested the attached app on R2023a and R2021b. It works fine for me. I do not have R2021a currently installed to test to see if it was a version issue.
Gillian Weir
on 24 Mar 2023
Adam Danz
on 24 Mar 2023
@Gillian Weir it looks like your tick label interpreter is set to none or latex. This solution requires a tex interpreter.
app.UIAxes.TickLabelInterpreter= 'tex';
Categories
Find more on Develop Apps Programmatically 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!
