Text Function for graph labels in App Designer

24 次查看(过去 30 天)
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!

采纳的回答

Rafnuss
Rafnuss 2019-7-24
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 个)

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by