Text Function for graph labels in App Designer

14 visualizaciones (últimos 30 días)
Joanna Peterschmitt
Joanna Peterschmitt el 23 de Jul. de 2019
Respondida: Rafnuss el 24 de Jul. de 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!

Respuesta aceptada

Rafnuss
Rafnuss el 24 de Jul. de 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')

Más respuestas (0)

Categorías

Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by