Set facecolor in app designer
조회 수: 4 (최근 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);
댓글 수: 0
채택된 답변
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
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 Center 및 File 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!