Set facecolor in app designer

5 vues (au cours des 30 derniers jours)
voxynn
voxynn le 25 Sep 2020
Commenté : Ameer Hamza le 25 Sep 2020
I have a circle in AppDesigner with different segments and I want to set the color of each segment individually. When I use the code below I get an error:
"Error using matlab.ui.control.UIAxes/set. Invalid parameter/value pair arguments."
However the same approch (without the app.UIAxes handle) works as expected in a normal script. Can someone point out to me where I might be going wrong?
x0=0;
r=10;
y0=0;
t1 = linspace(0,pi);
t2 = linspace(pi,2*pi);
x1 = x0 + r*cos(t1);
y1 = y0 + r*sin(t1);
x2 = x0 + r*cos(t2);
y2 = y0 + r*sin(t2);
pie=fill(app.UIAxes,[x0,x1,x0],[y0,y1,y0],'w-',...
[x0,x2,x0],[y0,y2,y0],'w-');
axis(app.UIAxes, 'equal');
box(app.UIAxes, 'off');
axis(app.UIAxes,'off');
set(app.UIAxes,pie(1),'facecolor',[255 85 180]./255);
set(app.UIAxes,pie(2),'facecolor',[255 0 0]./255);

Réponse acceptée

Ameer Hamza
Ameer Hamza le 25 Sep 2020
No need to pass app.UIAxes in these lines
set(pie(1),'facecolor',[255 85 180]./255);
set(pie(2),'facecolor',[255 0 0]./255);
  2 commentaires
voxynn
voxynn le 25 Sep 2020
Thank you! Not entirely sure why though...
Ameer Hamza
Ameer Hamza le 25 Sep 2020
I am glad to be of help!
The first input to set() is the handle of the graphic object you are trying to modify. You already have handles to patches. You don't need anything else.

Connectez-vous pour commenter.

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