画一个网络节点连接关系色彩图代码
主要调用函数pcolor, colorbar, colormap
clear;clc;
map=2*(rand(10)-0.5);
pcolor(map);
colorbar;
axis off;
但是细看会有问题,画的图少了一行,查看pcolor帮助文档
里面说默认的shadding模式为faceted,shadding总共3种模式,faceted(默认的),interp(对每个像素点插值),flat(去除方块黑线)。
还有就是pcolor如果不设定X,Y的话是按照1—2,2—3,3—4……作为一块涂色,为此设置X,Y,让画图小方块移到0.5—1.5,1.5—2.5……,这样一会儿可以直接在小方块对应的中心设置坐标。
function result=plotMatricNet_15(Features,Featuresweight)
figure
% 由于pcolor函数不处理最后一行和最后一列,所以这里补一行一列
weightMetrics=zeros(16);
Featuresweight=abs(Featuresweight);
for i=1:length(Features)
edge=Features(i);
[row,col]=electrodesIndex(edge,15);
weightMetrics(row,col)=Featuresweight(i);
weightMetrics(col,row)=Featuresweight(i);
end
% weightMetrics=maxmin(weightMetrics);
[X,Y]=meshgrid(0.5:1:15.5,0.5:1:15.5);
pcolor(X,Y,weightMetrics);
colorbar;
colormap(flipud(hot));
set(gca,'YTick',[1:1:15]);
set(gca,'XTick',[1:1:15]);
set(gca,'XTickLabel',{'F3','FZ','F4','FC3','FCZ','FC4','C3','CZ','C4','CP3','CPZ','CP4','P3','PZ','P4','null'})
set(gca,'YTickLabel',{'F3','FZ','F4','FC3','FCZ','FC4','C3','CZ','C4','CP3','CPZ','CP4','P3','PZ','P4','null'})
% shading flat;
% axis off;
result=true;