[Scilab-users] Scilab checkerboard plot (grayplot)

Samuel Gougeon sgougeon at free.fr
Sat Apr 22 10:58:31 CEST 2017


Hello Ekin,

Le 21/04/2017 à 11:19, Ekin Akoglu a écrit :
> Dear all,
>
> I am producing a checkerboard plot with Scilab and the plot seems 
> erroneously colored. The matrix I plot is attached as well as the 
> scripts to plot and the plot produced by Scilab.
>
> The problem is that the data at matrix(1,3) and matrix(1,4) are equal, 
> however, on the plot produced by Scilab it is represented by different 
> colors (plants vs det. feeders and plants vs carnivores on the plot). 
> Let me remind you that the plot is transposed form of the matrix.
>
> I would appreciate any help on the matter.

As Antoine wrote in his first answer, Matplot() must be used instead of 
grayplot().
The following simplified script can be used, yielding the following plot.

function  myMTIplot(data)

// Rescaling data to a given range of indices
nc  =  32;  // number of colors
zmin  =  -1;
zmax  =  1;
data2  =  (data  -  zmin)/(zmax-zmin)*(nc-1)  +  zmax;  

// Plotting
clf
f  =  gcf();
f.color_map  =  jetcolormap(nc);
Matplot(data2)
a  =  gca();
colorbar(zmin,  zmax);

a.sub_ticks(1)  =  0;
xlabel("Impacting Group",  "fontsize",4)
ylabel("Impacted Group",  "fontsize",  4)
title("Relative MTI",  "fontsize",  5);

[nrows,  ncols]  =  size(data);
a.font_size  =  3;
a.font_style  =  8;
a.x_ticks  =  tlist(["ticks",  "locations",  "labels"],  1:ncols,  ..
             ["Plants",  "Bacteria",  "Det. Feeders",  "Carnivores",  "Detritus"]);
a.y_ticks  =  tlist(["ticks",  "locations",  "labels"],  1:nrows,  ..
             ["Plants",  "Bacteria",  "Det. Feeders",  "Carnivores",  "Detritus"]);
//
endfunction

M  =  csvRead("matrix.csv");
myMTIplot(M)



It correctly maps the given data matrix:

--> data
  data  =

    0.   0.4665757   0.2895315   0.2895315   0.4778269
    0.  -0.2942464  -0.1630711  -0.1630711  -0.3005833
    0.  -0.1058069  -0.4451125   0.5548875  -0.0842439
    0.   0.0774553  -0.3547458  -0.3547458   0.0636698
    0.   0.6032754   0.3743599   0.3743599  -0.3821769

HTH
Samuel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20170422/a3e74a47/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cadkpdkopkidkfok.png
Type: image/png
Size: 17445 bytes
Desc: not available
URL: <https://lists.scilab.org/pipermail/users/attachments/20170422/a3e74a47/attachment.png>


More information about the users mailing list