matlab绘制热力图
Posted 小乖乖的臭坏坏
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了matlab绘制热力图相关的知识,希望对你有一定的参考价值。
data2=[0.617234569 0.617234569 4.320975309 0.617308642 4.320975309;
8.024567902 0.617234569 2.46908642 1.851814816 0.617308642;
0.617234569 1.851814816 0 0 1.851814816;
0.617308642 0.617308642 1.851814816 0.617308642 0;
0.617308642 0.617308642 0.617234569 0 0.617308642;
];
Pm=[0.05,0.1,0.15,0.2,0.25];
Pc=[0.0001,0.0005,0.001,0.005,0.01];
% [m,n]=meshgrid(1:6);
% surf(m,n,0*m,data1,'linestyle',':');
% %%%%%%%%%自定义颜色%%%%%%%%%%%
% map=ones(199,3);
% c=linspace(0,1)';
% map(199:-1:100,[2,3])=[c,c];
% map(1:100,[1,3])=[c,c];
% colormap(map);
% %colorbar([-50,50]);
% colorbar;
% %%%%%%%%%%%%%%%%%%%%%%%%%%
% view(2);axis ij
% axis([1,6,1,6])
% set(gca,'xtick',1.5:5.5,'xticklabel',Pm,'ytick',1.5:5.5,'yticklabel',Pc)
% [m,n]=meshgrid(1.5:5.5);
% %%%%%%%%显示百分比%%%%%%%%%%%%
% %text(m(:),n(:),cellfun(@(x)[num2str(x),'%'],num2cell(round(A(:)*100)),'UniformOutput',false),'HorizontalAlignment','center','color','b')
% text(m(:),n(:),cellfun(@(x)[num2str(x),'%'],num2cell(data1),'UniformOutput',false),'HorizontalAlignment','center','color','b')
% xlabel('Pm'),ylabel('Pc');
[m,n]=meshgrid(1:6);
surf(m,n,0*m,data2,'linestyle',':');
%%%%%%%%%自定义颜色%%%%%%%%%%%
% map=ones(199,3);
% c=linspace(0,1)';
% map(199:-1:100,[3,3])=[c,c];
% map(1:1:100,[2,3])=[c,c];
% colormap(map);
% %colorbar([-50,50]);
colorbar;
%%%%%%%%%%%%%%%%%%%%%%%%%%
view(2);axis ij
axis([1,6,1,6])
set(gca,'xtick',1.5:5.5,'xticklabel',Pm,'ytick',1.5:5.5,'yticklabel',Pc)
[m,n]=meshgrid(1.5:5.5);
%%%%%%%%显示百分比%%%%%%%%%%%%
%text(m(:),n(:),cellfun(@(x)[num2str(x),'%'],num2cell(round(A(:)*100)),'UniformOutput',false),'HorizontalAlignment','center','color','b')
text(m(:),n(:),cellfun(@(x)[num2str(x)],num2cell(data2),'UniformOutput',false),'HorizontalAlignment','center','color','b')
xlabel('高变异率'),ylabel('低变异率');
运行结果:
可以依照
https://blog.csdn.net/weixin_42887138/article/details/116504243
提到的方法来更改图片颜色,得到下图:
作于:
2021-5-7
23.09
以上是关于matlab绘制热力图的主要内容,如果未能解决你的问题,请参考以下文章