Set facecolor in app designer

2 次查看(过去 30 天)
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);

采纳的回答

Ameer Hamza
Ameer Hamza 2020-9-25
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 个评论
voxynn
voxynn 2020-9-25
Thank you! Not entirely sure why though...
Ameer Hamza
Ameer Hamza 2020-9-25
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by