You are now following this Submission
- You will see updates in your followed content feed
- You may receive emails, depending on your communication preferences
Basic usage
X = [1 3 0.5 2.5 2];
% Create hatched pie chart object
HP = hatchedPie(X, 'HatchType',{'/','.','|','+','x'});
% Draw hatched pie chart
HP = HP.draw();
% Hatch Type
% ==========================================
% "/" — Forward diagonal
% "\" — Backward diagonal
% "_"/"-" — Horizontal
% "|" — Vertical
% "+" — Cross
% "x" — Diagonal Cross
% "." — Dot
% "w"/"W"/"white" — White
% "k"/"K"/"black" — Black
% "gray"/"grey" — Gray
% ==========================================
Hatched pie chart with offset slices and legend
X = [1 3 0.5 2.5 2];
explode = [0 1 0 5 0];
% Create hatched bar chart object with offset slices
HP = shadowPie(X, explode, 'HatchType',{'/','.','|','+','x'});
HP = HP.draw();
% Create legend
HP.legend({'AAA','BBB','CCC','DDD','EEE'}, 'FontSize',13, 'FontName','Cambria');
Face color
clc; clear; close all
X = [1 3 0.5 2.5 2];
explode = [0 1 0 5 0];
% Create hatched bar chart object with offset slices
HP = shadowPie(X, explode, 'HatchType',{'/','.','|','+','x'});
HP = HP.draw();
% Create legend
HP.legend({'AAA','BBB','CCC','DDD','EEE'}, 'FontSize',13, 'FontName','Cambria');
% Change face color
% Palette: user-defined nx3 matrix (values in [0,1])
colorList = [ 52 101 117
121 172 189
155 177 187
236 189 149
228 222 206]./255;
% Since both legend and pie chart are patch objects,
% detect whether a legend exists and apply coloring accordingly in two cases.
pieHdl = findobj(gca, 'Type','Patch', 'Tag','pieBox');
if ~isempty(findobj(gca, 'Tag','lgdBox'))
for i = 1:length(pieHdl)/2
set(pieHdl(length(pieHdl)/2 + 1 - i), 'FaceColor',colorList(i,:))
set(pieHdl(length(pieHdl)/2 + 1 - i + length(pieHdl)/2), 'FaceColor',colorList(i,:))
end
else
for i = 1:length(pieHdl)
set(pieHdl(length(pieHdl) + 1 - i), 'FaceColor',colorList(i,:))
end
end
Cite As
Zhaoxu Liu / slandarer (2026). hatched pie chart (阴影/条纹填充饼图) (https://uk.mathworks.com/matlabcentral/fileexchange/117045-hatched-pie-chart), MATLAB Central File Exchange. Retrieved .
General Information
- Version 2.0.1 (238 KB)
MATLAB Release Compatibility
- Compatible with any release
Platform Compatibility
- Windows
- macOS
- Linux
