% plot bar graph with patterns
% b1: output of original "bar" matlab function
% varargin <= input of original "bar" matlab function
% patterns: {'\','/','*','-','|','+', ' ', 's'} (solid filled)
% lcolor: line color {[R G B]} between 0-1
% lspacing: {1}: space between lines
% lwidth: {1}: line width of patterns
% * if the size of input not match with the data, using the first unit for all bars
% %Example 1:
% figure(1);clf;set(gcf,'color','w');
% dataBar=rand(3,5)-0.5;
% patterns={'\*+ s','\*+ s','\*+ s'};
% lcolor={lines(5),lines(5),lines(5)};
% lspacing={[1 1 1 1 1],[1 1 1 1 1],[1 1 1 1 1]};lwidth={[1 1 1 1 1],[1 1 1 1 1],[1 1 1 1 1]};
% b1=bar_pattern(patterns,lcolor,lspacing,lwidth,dataBar,'FaceColor',[1 1 1],'BarWidth',1);
% b1(5).FaceAlpha = 0.5;
%
% %Example 2:
% figure(2);set(gcf,'color','w')
% dataBar=rand(1,5)-0.5;
% patterns={'/-\ s'};lcolor={jet(5)};lspacing={[1 1 1 1 1]};lwidth={[1 1 1 1 1]};
% b1=bar_pattern(patterns,lcolor,lspacing,lwidth,dataBar,'FaceColor',[1 1 1]);
%
% %Example 3: Apply with bar
% figure(3);set(gcf,'color','w');
% dataBar=rand(3,5)-0.5;
% patterns={'/+\ x','/+\ x','/+\ s'};
% lcolor={lines(5),lines(5),lines(5)};
% lspacing={[1 1 1 1 1],[1 1 1 1 1],[1 1 1 1 1]};lwidth={[2 2 2 2 2],[2 2 2 2 2],[2 2 2 2 2]};
% b1=bar_pattern(patterns,lcolor,lspacing,lwidth,dataBar,'FaceColor',[1 1 1],'BarWidth',1,'LineWidth',2);
% b1=bar(dataBar,'FaceAlpha',0.2,'BarWidth',1,'LineWidth',2,'FaceColor','flat');hold on;
% set(gca,'FontWeight','bold','LineWidth',2,'FontSize',20,'xticklabel',{'A','B','C'})
인용 양식
Chaohsiung Hsu (2025). Plot bar graph with patterns (https://www.mathworks.com/matlabcentral/fileexchange/126849-plot-bar-graph-with-patterns), MATLAB Central File Exchange. 검색 날짜: .
MATLAB 릴리스 호환 정보
개발 환경:
R2023a
R2021b 이상 릴리스와 호환
플랫폼 호환성
Windows macOS Linux태그
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!버전 | 게시됨 | 릴리스 정보 | |
---|---|---|---|
1.0.0 |