资源简介
matlab 绘制 阴影 黑白 柱状图 条形图, 本来想免费发布,但csdn必须设置资源分数,如果需要请私信我。
代码片段和文件信息
function applyhatch(hpatternscolorlist)
%APPLYHATCH Apply hatched patterns to a figure
% APPLYHATCH(HPATTERNS) 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(HPATTERNSCOLORS) 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(34));
% applyhatch(gcf‘\-x.‘);
%
% Example 2:
% colormap(cool(6));
% pie(rand(61));
% legend(‘Jan‘‘Feb‘‘Mar‘‘Apr‘‘May‘‘Jun‘);
% applyhatch(gcf‘|-+.\/‘cool(6));
%
% See also: MAKEHATCH
% By Ben Hinkle
% This code is in the public domain.
oldppmode = get(h‘paperpositionmode‘);
oldunits = get(h‘units‘);
set(h‘paperpositionmode‘‘auto‘);
set(h‘units‘‘pixels‘);
figsize = get(h‘position‘);
if nargin == 2
colorlist = [];
end
bits = hardcopy(h‘-dzbuffer‘‘-r0‘);
set(h‘paperpositionmode‘oldppmode);
bwidth = size(bits2);
bheight = size(bits1);
bsize = bwidth * bheight;
if ~isempty(colorlist)
colorlist = uint8(255*colorlist);
[colorscolori] = nextnonbw(0colorlistbits);
else
colors = (bits(::1) ~= bits(::2)) | ...
(bits(::1) ~= bits(::3));
end
pati = 1;
colorind = find(colors);
while ~isempty(colorind)
colorval(1) = bits(colorind(1));
colorval(2) = bits(colorind(1)+bsize);
colorval(3) = bits(colorind(1)+2*bsize);
if iscell(patterns)
pattern = patterns{pati};
elseif isa(patterns‘char‘)
pattern = makehatch(patterns(pati));
else
pattern = patterns;
end
pattern = uint8(255*(1-pattern));
pheight = size(pattern2);
pwidth = size(pattern1);
ratioh = ceil(bheight/pheight);
ratiow = ceil(bwidth/pwidth);
bigpattern = repmat(pattern[ratioh ratiow]);
if ratioh*pheight > bheight
bigpattern(bheight+1:end:) = [];
end
if ratiow*pwidth > bwidth
bigpattern(:bwidth+1:end) = [];
end
bigpattern = repmat(bigpattern[1 1 3]);
color = (bits(::1) == colorval(1)) & ...
(bits(::2) == colorval(2)) & ...
(bits(::3) == colorval(3));
color = repmat(color[1 1 3]);
bits(color) = bigpattern(color);
if ~isempty(colorlist)
[colorscolori] = nextnonbw(coloricolorlistbits);
else
colors = (bits(::1) ~= bits(::2)) | ...
(bits(::1) ~= bits(::3));
end
colorind = find(colors);
pati = (pati + 1);
if pati > length(patterns)
pati = 1;
end
end
newfig = figure(‘units‘‘pixels‘‘visible‘‘off‘);
imaxes = axes(‘parent‘newfig‘units‘‘pixels‘);
im = image(bits‘parent‘imaxes);
fpos = get(newfig‘position‘);
set(newfig‘posit
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3563 2018-04-18 21:32 figure\applyhatch.m
文件 796 2018-04-21 12:18 figure\main_top.m
文件 954 2018-04-18 21:34 figure\makehatch.m
目录 0 2018-04-21 12:18 figure\
- 上一篇:10用户CDMA matlab实现
- 下一篇:matlab NS 单车道
相关资源
- matlab NS 单车道
- 10用户CDMA matlab实现
- 图像对比度计算MATLAB代码
- kruskal算法最小生成树聚类MATLAB源程序
- matlab实现的随机森林算法
- 雷克子波程序
- matlab生成菲涅尔透镜
- matlab程序信噪比
- 求根MUSIC算法
- 偏微分方程定解问题的有限元方法M
- 基于MATLAB图像加解密程序
- 凸规划matlab程序
- matlab读入三维点云数据斯坦福兔子
- 极限学习机matlab源代码
- MATLAB 求解PDE偏微分方程工具箱及
- 二维navier-Stokes (非定常)MATALAB
- 《功率变换器和电气传动的预测控制
- 基于MATLAB并结合IBD算法的盲迭代反卷
- 基于matlab图像复原处理包,其中包括
- adams与matlab联合仿真
- MATLAB的GUI界面的实时绘图显示
- qpsk matlab代码
- matlab 遗传算法公交车路线优化
- MATLAB题库很好用
- 六自由度机械臂三维仿真程序完整版
- MATLAB 工程案例.
- DE差分进化算法MATLAB源码,中文详细注
- MARLAB 入门MATLAB 数学工具软件 简明教
- 最新MATLAB激活许可证,解决2017-11-12后
- GRD格式的DEM文件读取写入Matlab程序.
评论
共有 条评论