MATLAB Answers

Using a Checkbox to add/ remove Text in contourplot in Appdesigner

조회 수: 1(최근 30일)
Jan Kosytorz
Jan Kosytorz 2021년 9월 14일
답변: Cris LaPierre 2021년 9월 15일
Hey,
i'm would like to know, how to use a Checkbox to activate the text of the ISO- Lines in a contourf- plot in the Matlab Appdesigner.
Usually i write this in Scripts:
[c1,p1] = contourf(x,y,z,numberofISOlines);
clabel(c1,p1,'FontWeight','bold','FontSize',4,'Color','w','FontName','Courier');%Example
So in Appdesigner i wrote:
contourf(app.UIAxes1,x,y,z,numberofISOlines);
..and tried to activate Text with a checkbox in the same way i used to activate for example a colormap:
This works:
function ColorbarCheckBoxValueChanged(app, event)
valuecolormap = app.ColorbarCheckBox.Value;
if valuecolormap == true
colorbar(app.UIAxes1,"eastoutside")
else
colorbar(app.UIAxes1,"off")
end
end
So i can insert a colorbox in my current plot without updating/ recalculating the plots
This doesn't work:
function ISOtextCheckBoxValueChanged(app, event)
valueISOtext = app.ISOtextCheckBox.Value;
if valueISOtext == true
ShowText(app.UIAxes1,'on')
else
ShowText(app.UIAxes1,'off')
end
end
Asan Issue i get this:
Undefined function 'ShowText' for input arguments of type 'matlab.ui.control.UIAxes'.
So i probably use the ShowText in a wrong way .
Does someone have a solution for this? Thanks in advance!

채택된 답변

Cris LaPierre
Cris LaPierre 2021년 9월 15일
You need to use the handle to your contour plot to set the property of ShowText to on or off.
[x,y,z] = peaks;
[C,h] = contour(x,y,z);
h.ShowText='on';

추가 답변(0개)

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by