如何在matlab中画有阴影的柱状图,Matlab中画有阴影的柱状图.doc

Matlab中画有阴影的柱状图

在画柱状图时,利用不同的颜色区分在实际打印时经常区分不出。 为了能够更清楚第表示最终结果,可采用在柱状图中打阴影的方式来表示。

然而,Matalab本身没有提供实现这种功能的函数库。

下面两个函数:

% Apply Brandon's function

applyhatch_pluscolor

% Apply Brian's function

applyhatch_plusC(fH, '\-x.', 'rkbk');

实现了上述功能。

这两个函数中都调用了函数makehatch_plus 源码如下(都已经调试通过,可方便使用)。

fH = gcf; colormap(jet(4));

h = bar(rand(3, 4));

legend('Apple', 'Orange', 'Banana', 'Melon', 'Location', 'EastOutside');

% Apply Brandon's function

tH = title('Brandon''s applyhatch');

applyhatch_pluscolor(fH, '\-x.', 0, [1 0 1 0], jet(4));

% Apply Brian's function

set(tH, 'String', 'Brian''s applyhatch');

applyhatch_plusC(fH, '\-x.', 'rkbk');

set(tH, 'String', 'Original');

代码源自:

/matlabcentral/fileexchange/24021-hatch-fill-patterns-plus-color-invert/content/applyhatch_pluscolor.m

function [im_hatch,colorlist] = applyhatch_pluscolor(h,patterns,CvBW,Hinvert,colorlist, ...

dpi,hatchsc,lw)

%APPLYHATCH_PLUSCOLOR Apply hatched patterns to a figure in BW or Color

% APPLYHATCH_PLUSCOLOR(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', '.', 'c', 'w', 'k'

% (see makehatch_plus.m for more details) or

% a cell array of matrices of zeros (white) and ones (black)

%

% In addition, H can alternatively be a uint8 NxMx3 matrix of the type

% produced by imread. In this case, colors in this image will be

% replaced with patterns as if it was a figure. A final figure window

% will be generated that displays the result. The DPI argument

% discussed below will be ignored if H is an image matrix.

%

% APPLYHATCH_PLUSCOLOR(H,PATTERNS,CVBW) binary value for choice of Color or Black

% and White plots. If color is chosen the color will match that of the

% current fill. 1 -> Color, anything else -> BW

%

% APPLYHATCH_PLUSCOLOR(H,PATTERNS,CVBW,HINVERT) binary value to invert the h

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值