码迷,mamicode.com
首页 > 其他好文 > 详细

matlab画图之pcolor函数

时间:2015-04-08 18:19:28      阅读:2554      评论:0      收藏:0      [点我收藏+]

标签:

      画一个网络节点连接关系色彩图代码

     主要调用函数pcolor, colorbar, colormap

     

clear;clc;
map=2*(rand(10)-0.5);
pcolor(map);
colorbar;
axis off;

      其中colorbar函数会自动匹配map里面值的大小。
      结果如下:
技术分享

      但是细看会有问题,画的图少了一行,查看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;


技术分享

matlab画图之pcolor函数

标签:

原文地址:http://blog.csdn.net/zhangzhengyi03539/article/details/44942083

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!