資源簡介
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 單車道
評論
共有 條評論