Plot bar graph with patterns
Versión 1.0.0 (2,82 KB) por
Chaohsiung Hsu
Plot bar graph with patterns
% 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'})
Citar como
Chaohsiung Hsu (2025). Plot bar graph with patterns (https://www.mathworks.com/matlabcentral/fileexchange/126849-plot-bar-graph-with-patterns), MATLAB Central File Exchange. Recuperado .
Compatibilidad con la versión de MATLAB
Se creó con
R2023a
Compatible con cualquier versión desde R2021b
Compatibilidad con las plataformas
Windows macOS LinuxEtiquetas
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Descubra Live Editor
Cree scripts con código, salida y texto formateado en un documento ejecutable.
Versión | Publicado | Notas de la versión | |
---|---|---|---|
1.0.0 |