Text Function for graph labels in App Designer
14 views (last 30 days)
Show older comments
Does anyone know how to include a text label above every data point on a graph in MatLab app designer? In regular code, this would look like this
x=[0 1 2 3 4 5 6 7 8 20]; %weeks
y=[8 8 4 7 6 5 4 3 5 4]; %scores
tx = [0 0 50 12.5 25 37.5 50 62.5 37.5 50]; %percent reduction of score compared to week 0
tx = num2cell(round(tx)); % must be in cells to be labels
tx = cellfun(@num2str, tx, 'un', 0);
tx = strcat(tx, '%');
plot(x, y); hold on
text(x, y, tx, 'VerticalAlignment','bottom')
and the figure generated would be the following
I am trying to recreate this in app designer but running into some issues. I tried using the text function and a label object but neither have been successful.
thanks!
0 Comments
Accepted Answer
Rafnuss
on 24 Jul 2019
Don't forget to put the axes in the function
text(app.ax,_)
so, in your case, if your figure axes in the GUI is app.ax :
text(app.ax, x, y, tx, 'VerticalAlignment','bottom')
0 Comments
More Answers (0)
See Also
Categories
Find more on Develop Apps Using App Designer 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!