没有合适的资源?快使用搜索试试~ 我知道了~
如何在Matlab中画有阴影的柱状图.doc
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 110 浏览量
2022-07-05
08:04:08
上传
评论
收藏 115KB DOC 举报
温馨提示
![preview](https://dl-preview.csdnimg.cn/85903714/0001-084dbe7534d9ff2e7d3cfdaedf5c8f98_thumbnail.jpeg)
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
试读
15页
如何在Matlab中画有阴影的柱状图
资源推荐
资源详情
资源评论
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/release/download_crawler_static/85903714/bg1.jpg)
在画柱状图时,利用不同的颜色区分在实际打印时经常区分不出。 为了能够更清楚第表示最终结果,可采
用在柱状图中打阴影的方式来表示。
然而,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');
![](https://csdnimg.cn/release/download_crawler_static/85903714/bg2.jpg)
代码源自:
http://www.mathworks.com/matlabcentral/fileexchange/24021-hatch-fill-patterns-plus-color-inv
ert/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 hatch.
% i.e., if it is black lines with a white background, that becomes white
% lines with a black background. This can either be a scalar value or a
% 1xN array equal to the length of PATTERNS. When used as an array each
% PATTERNS(i) will be inverted according to Hinvert(i). 1 -> Invert,
% anything else -> Non Inverted
%
% APPLYHATCH_PLUSCOLOR(H,PATTERNS,CVBW,HINVERT,COLORS) maps the colors in the n by 3
![](https://csdnimg.cn/release/download_crawler_static/85903714/bg3.jpg)
% 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 bitmap output.
%
% Additional arguments:
%
% [im_hatch,colorlist] =
applyhatch_plus(h,patterns,CvBW,Hinvert,colorlist,dpi,hatchsc,linewidth)
%
% input DPI allows specification of bitmap resolution, making plot resolution
% better for printing. Ignored if H is an image matrix.
% HATCHSC multiplier for hatch scale to increase size of pattern for better
operation
% at higher resolutions
% default [] uses screen resolution as in
% APPLYHATCH
% LINEWIDTH A scaling factor to apply to line and dot sizes
% in hatching. Defaults to 1.
% output IM_HATCH RGB bitmap matrix of new figure
% use IMWRITE to output in desired format
% COLORLIST List of colors actually replaced. Useful info if
% no colorlist initially given to function.
% Colorlist will be uint8, not 0-1 scale as
% originally specified.
%
% Example 1:
% bar(rand(3,4));
% [im_hatch,colorlist] = applyhatch_pluscolor(gcf,'\-x.',0,0,[],150);
% imwrite(im_hatch,'im_hatch.png','png')
%
% Example 2:
% bar(rand(3,4));
% [im_hatch,colorlist] = applyhatch_pluscolor(gcf,'\-x.',1,[],[],150);
% imwrite(im_hatch,'im_hatch.png','png')
%
% Example 3:
% colormap(cool(6));
% pie(rand(6,1));
% legend('Jan','Feb','Mar','Apr','May','Jun');
% im_hatch = applyhatch_pluscolor(gcf,'|-.+\/',1,[1 1 0 1 0 0],cool(6),200,3,2);
% imwrite(im_hatch,'im_hatch.png','png')
%
剩余14页未读,继续阅读
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/default.jpg!1)
omyligaga
- 粉丝: 54
- 资源: 2万+
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)