Plot‎ > ‎Bar plot‎ > ‎

Barplot percentage

Plot percentage data as filled bars


% generate percentage data
perc = [8; 70; 5; 3; 50; 65]; perc = flipud(perc);

% horizontal bar-plot
barpairs = [perc,100-perc] % get paired values for perc-box and 100-perc-box
h = barh(1:numel(perc),barpairs,'stacked'); multi-box "stacked" bar plot
set(h(1),'FaceColor',[0.7,0.8,1]); % set color of perc-box blue
set(h(2),'FaceColor',[1,1,1]); % set color of 100-perc-box white
axis off



see also
→ horizontal histogram
→ https://mathworks.com/help/matlab/ref/colorspec.html