绘制Matlab中的双变量映射

时间:2017-11-19 17:42:01

标签: matlab gis

我有两张地图(矩阵),并希望用它们来生成相应的双变量地图。

下面的代码说明了使用'scatter'的想法,但由于我的原始矩阵非常大,我需要一个不同的解决方案而不是单独绘制每个点。

 red_blue_colormap = brewermap(20,'RdYlBu'); %using ColorBrewer colormaps 'brewermap'
 white2red = newmap(10:-1:1,:); %color map going from white to red
 white2blue = newmap(11:20,:); %color map going from white to blue

 X = rand(13,8); Y  = rand(13,8);  %sample matrices

 figure;
 for i=1:size(X,1)
   for j=1:size(X,2)
     portion_red = white2red(ceil(X(i,j)*10),:); %value between 'white' and 'red' corresponding to value of X(i,j)
     portion_blue = white2blue(ceil(Y(i,j)*10),:);

     subplot(2,2,1); hold on; title('X');
       scatter(i,j,100,portion_red ,'s','filled');
     subplot(2,2,2); hold on; title('Y'); 
       scatter(i,j,100,portion_blue ,'s','filled'); 

     subplot(2,2,3); hold on;  title('X vs. Y');
       w1 = Y(i,j)/(X(i,j) + Y(i,j)); %relative weight of 'Y'
       color1 = portion_red - ((portion_red - portion_blue ) * w1);        
       scatter(i,j,100,color1,'s','filled');

     subplot(2,2,4); hold on; title('Color matrix');
       portion_red = white2red(ceil(i/size(X,1)*10),:);
       portion_blue = white2blue(ceil(j/size(X,2)*10),:);        
       w2 = (j/size(X,2))/(i/size(X,1) + j/size(X,2));
       color2 = portion_red - ((portion_red - portion_blue ) * w2);
       scatter(i,j,100,color2,'s','filled');
  end
end

这会生成下图:https://image.ibb.co/kotP7m/bivariate_map.png

我想以更有效的方式绘制左下图。有什么想法吗?

0 个答案:

没有答案