Text Function for graph labels in App Designer

24 vues (au cours des 30 derniers jours)
Joanna Peterschmitt
Joanna Peterschmitt le 23 Juil 2019
Réponse apportée : Rafnuss le 24 Juil 2019
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!

Réponse acceptée

Rafnuss
Rafnuss le 24 Juil 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')

Plus de réponses (0)

Catégories

En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by