Plotting matrix

Mathieu Dubois mathieu.dubois at limsi.fr
Thu Oct 14 21:02:49 CEST 2010


Hello,

I would like to represent data in a matrix by coloured small circles 
(for gnuplot users I want to reproduce something like the "with points" 
option).


The following script works but is rather slow. axis is a handle the axes 
and h a handle to the figure (it is hidden before the script and then 
reshowed to speed up the rendering).
The data are probabilities so the scaling is simple. The circles are 
approximated by 10 facets polygons which is not very beautiful. The 
probability gives the radius of the circle and its colour.

axis.data_bounds=[0.0 0.0; n_states, n_states];
     h.visible="off";
     // Colormap length
     n_colors=size(h.color_map, 1);
     for i=1:n_states
         for j=1:n_states
             //j=i
             if a(i, j)>0.1
                 xrpoly([i, j], 10, a(i, j));
             else
                 xrpoly([i, j], 10, 0.1);
             end
             e=gce();
             e.fill_mode="on";
             color_=int(a(i, j)*n_colors);
             e.foreground=color_;
             e.background=color_;
         end
     end
     h.visible="on"

Any idea to improve it?
Mathieu



More information about the users mailing list