日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 人工智能 > 循环神经网络 >内容正文

循环神经网络

matlab bar 填充花纹,转:使用matlab绘画柱状图,且使用不同的图案填充

發(fā)布時(shí)間:2023/12/20 循环神经网络 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 matlab bar 填充花纹,转:使用matlab绘画柱状图,且使用不同的图案填充 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

在論文中,圖表往往發(fā)揮著極為重要的作用,好的圖表將能進(jìn)一步提升論文的質(zhì)量。在書寫論文時(shí),很多時(shí)候需要繪制柱狀圖,然而不同的柱狀圖如果采用顏色區(qū)分,當(dāng)論文打印以后,視覺效果大打折扣,甚至無(wú)法區(qū)分。在遇到這個(gè)問(wèn)題時(shí),我通過(guò)網(wǎng)站論壇搜索,終于找到了在matlab中繪制柱狀圖,并采用不同的圖案進(jìn)行表示。主要利用下面的代碼。

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','May','Jun');

%?applyhatch(gcf,'|-+.\/',cool(6));

%

%?See also: MAKEHATCH

%?By Ben Hinkle, bhinkle@mathworks.com

%?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(bits,2);

bheight = size(bits,1);

bsize = bwidth * bheight;

if ~isempty(colorlist)

colorlist = uint8(255*colorlist);

[colors,colori] =

nextnonbw(0,colorlist,bits);

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(pattern,2);

pwidth = size(pattern,1);

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)

[colors,colori] = nextnonbw(colori,colorlist,bits);

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,'position',[fpos(1:2) figsize(3) figsize(4)+1]);

set(imaxes,'position',[0 0 figsize(3)

figsize(4)+1],'visible','off');

set(newfig,'visible','on');

function [colors,out] =

nextnonbw(ind,colorlist,bits)

out = ind+1;

colors = [];

while out <= size(colorlist,1)

if isequal(colorlist(out,:),[255 255 255]) |

...

isequal(colorlist(out,:),[0 0 0])

out =

out+1;

else

colors =

(colorlist(out,1) == bits(:,:,1)) & ...

(colorlist(out,2) == bits(:,:,2)) & ...

(colorlist(out,3) == bits(:,:,3));

return

end

end

而applyhatch函數(shù)需要調(diào)用下面的函數(shù)

function A = makehatch(hatch)

%MAKEHATCH Predefined hatch patterns

%?MAKEHATCH(HATCH) returns a

matrix with the hatch pattern for HATCH

%?according to the following

table:

%?HATCH?pattern

%?-------?---------

%?/?right-slanted lines

%?\?left-slanted lines

%?|?vertical lines

%?-?horizontal lines

%?+?crossing vertical and horizontal lines

%?x?criss-crossing lines

%?.?single dots

%

%?See also: APPLYHATCH

%?By Ben

Hinkle, bhinkle@mathworks.com

%?This code is in the public domain.

n = 6;

A=zeros(n);

switch (hatch)

case '/'

A = fliplr(eye(n));

case '\'

A = eye(n);

case '|'

A(:,1) = 1;

case '-'

A(1,:) = 1;

case '+'

A(:,1) = 1;

A(1,:) = 1;

case 'x'

A = eye(n) | fliplr(diag(ones(n-1,1),-1));

case '.'

A(1:2,1:2)=1;

otherwise

error(['Undefined hatch pattern "' hatch

'".']);

end

效果如下圖所示

總結(jié)

以上是生活随笔為你收集整理的matlab bar 填充花纹,转:使用matlab绘画柱状图,且使用不同的图案填充的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。