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

2 ビュー (過去 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 件)

カテゴリ

Help Center および File ExchangeContour Plots についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by