matlab 柱状图 斜线,请教一个关于柱状图的问题--填充采用斜线之类的,不能是颜色...

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

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函数需要调用下面的函数

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值