Reputation: 311
I was writing a little script to start getting used to waitbars in MATLAB and I wanted to set the edge color of the waitbar to green and the face color to blue but it just doesn't work; I keep getting the face color in green and the edge in black. Here's the code:
wb=waitbar(0,'Iterating...');
set(wb,'Name','Changing color');
wbobject=findobj(wb,'Type','Patch');
set(wbobject,'EdgeColor',[0 1 0],'FaceColor',[0 0 1]);
for i=1:1000
waitbar(i/1000)
end
delete(wb);
An additional question: Would you mind explaining or referring me to a source in order to understand what is a patch in MATLAB?
Thank you!
Upvotes: 1
Views: 445
Reputation: 65430
You aren't able to see the change in EdgeColor
because the waitbar
figure contains a line
object which is that outline. You'll want to find that line object and change the Color
property of it
wb=waitbar(0,'Iterating...');
set(wb,'Name','Changing color');
wbobject=findobj(wb,'Type','Patch');
set(wbobject,'EdgeColor',[0 1 0],'FaceColor',[0 0 1]);
hline = findall(wb, 'type', 'line');
set(hline, 'Color', [0 1 0]);
Also a patch
object is described in the documentation. It is essentially a filled polygon. waitbar
uses one to represent the rectangle that indicates the progress.
Upvotes: 1