在论文中,图表往往发挥着极为重要的作用,好的图表将能进一步提升论文的质量。在书写论文时,很多时候需要绘制柱状图,然而不同的柱状图如果采用颜色区分,当论文打印以后,视觉效果大打折扣,甚至无法区分。在遇到这个问题时,我通过网站论坛搜索,终于找到了在matlab中绘制柱状图,并采用不同的图案进行表示。主要利用下面的代码。
function applyhatch(h,patterns,colorlist)
%APPLYHATCH Apply hatched patterns to a figure
% APPLYHATCH(H,PATTERNS) creates a new figure from the figure H by
% replacing distinct colors in H with the black and white
% patterns in PATTERNS. The format for PATTERNS can be
% a string of the characters '/', '', '|', '-', '+', 'x', '.'
% a cell array of matrices of zeros (white) and ones (black)
%
% APPLYHATCH(H,PATTERNS,COLORS) maps the colors in the n by 3
% matrix COLORS to PATTERNS. Each row of COLORS specifies an RGB
% color value.
%
% Note this function makes a bitmap image of H and so is limited
% to low-resolution, bitmap output.
%
% Example 1:
% bar(rand(3,4));
% applyhatch(gcf,'-x.');
%
% Example 2:
% colormap(cool(6));
% pie(rand(6,1));
% legend('Jan','Feb','Mar','Apr'