Text Function for graph labels in App Designer

조회 수: 14 (최근 30일)
Joanna Peterschmitt
Joanna Peterschmitt 2019년 7월 23일
답변: Rafnuss 2019년 7월 24일
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