Set facecolor in app designer

2 views (last 30 days)
voxynn
voxynn on 25 Sep 2020
Commented: Ameer Hamza on 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);

Accepted Answer

Ameer Hamza
Ameer Hamza on 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 Comments
voxynn
voxynn on 25 Sep 2020
Thank you! Not entirely sure why though...
Ameer Hamza
Ameer Hamza on 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.

Sign in to comment.

More Answers (0)

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!