matlab绘制不同区域不同色彩的图,并显示数据(代码)

绘图结果如下:

代码如下:

A为绘图的数据,每个数据对应着上图中的一个区域,数据大小决定区域的颜色

% 假设有一系列的数据点  
A=rand(5,6);      %A为绘图的数据,数据大小决定颜色
wei_shu='%.3f';   %代表数据保留三位小数  保留两位则改为  '%.2f'



nlie=size(A,2);
nhang=size(A,1);


ny=nhang+1;
nx=nlie+1;

  figure
hold on
data=A;
imagesc(data);
axis equal
axis off

for iy=1:nhang
    for ix=1:nlie
AAAF=num2str(data(iy,ix),wei_shu);  %数字转为字符
%text(iy-0.4,ix+0.25,'主婧出品', 'FontSize', 12, 'Color', 'black', 'Rotation', 45)
text(ix-0.25,iy, AAAF, 'FontSize', 12, 'Color', 'black', 'Rotation', 0)
    end
end
    %%%%%%%%%%%%%%%%%%%%%增加黑色线条框框
x_points=zeros(1,ny);
y_points=zeros(1,ny);
for iy=1:ny
    for ix=1:nx
x_points(1,ix)=ix-0.5;
y_points(1,ix)=iy-0.5;
    end
    plot(x_points,y_points,'k-');
end
x_points=zeros(1,ny);
y_points=zeros(1,ny);
for ix=1:nx
    for iy=1:ny

x_points(1,iy)=ix-0.5;
y_points(1,iy)=iy-0.5;
    end
    plot(x_points,y_points,'k-');
end

title('数据彩色图');

hold off

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值