[Scilab-users] ?==?utf-8?q? ?==?utf-8?q? ?= Scilab checkerboard plot (grayplot

Antoine Monmayrant antoine.monmayrant at laas.fr
Sat Apr 22 08:39:09 CEST 2017


Le Vendredi, Avril 21, 2017 14:27 CEST, Ekin Akoglu <ekinakoglu at gmail.com> a écrit: 
 
> Dear Antoine,
> 
> Thank you very much for the resolution. It solves my problem by 
> producing a graphically consistent plot. However, data-wise, the 
> colorbar does not match the plot unless I rescale it to (1,32). I want 
> to be able to infer the approximate value of the data from the colors. 
> However, thank you.

Well, I don't use colorbar.
I usually replot a dummy rectangle that contains like this:
nc=32://number of colors
Rect=[linspace(min(data),max(data),nc);linspace(min(data),max(data),nc)]
I plot it in a second axis next to the one with the actual data and than set the ticks labels by hand to display the nc values.

Antoine

> 
> Kind regards,
> 
> Ekin
> 
> 
> On 21/04/17 14:25, Antoine Monmayrant wrote:
> > Le Vendredi, Avril 21, 2017 11:19 CEST, Ekin Akoglu <ekinakoglu at gmail.com> 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.
> >>
> >> Kind regards,
> >>
> >> Ekin
> >>
> >   
> > Hello,
> >
> > The default behavior for grayplot is to paint a given pixel (a given square) with the color corresponding to its four corners.
> > See: "help data_mapping"
> >   You can either change the data_mapping after calling grayplot or use Matplot.
> > However, you'll have to rescale your data so that it ranges from 1 to nc where nc is the number of colors in your color_map.
> > See my modified function below.
> > Does it solve your problem?
> >
> > Cheers,
> >
> > Antoine
> >
> > function myMTIplot(data)
> >
> > [nrows ncols] = size(data);
> >
> > data = [zeros(1,ncols); data; zeros(1,ncols)];
> > data = [zeros(1,nrows+2)' data zeros(1,nrows+2)'];
> >
> > [nrows ncols] = size(data);
> >
> > figure1 = scf();
> > a = newaxes();
> >
> > colorbar(-1, 1);
> > grayplot(1:nrows, 1:ncols, data);
> >
> > figure1.color_map = jetcolormap(32);
> >
> > a.y_label.text = "Impacted Group";
> > a.y_label.font_size = 4;
> > a.x_label.text = "Impacting Group";
> > a.x_label.font_size = 4;
> > a.title.text = "Relative MTI";
> > a.title.font_size = 5;
> > a.font_size = 4;
> > a.data_bounds = [1, 6, 1, 6];
> >
> > a.x_ticks = tlist(["ticks", "locations", "labels"], (1.5:1:5.5), ["Plants", "Bacteria", "Det. Feeders", "Carnivores", "Detritus"]);
> > a.y_ticks = tlist(["ticks", "locations", "labels"], (1.5:1:5.5), ["Plants", "Bacteria", "Det. Feeders", "Carnivores", "Detritus"]);
> >
> >
> > //new version without interpolation
> > // we rescale the data so that is goes from 1 to 32
> > dat=(data-min(data))/(max(data)-min(data))*31+1;
> > figure2 = scf();
> > a = newaxes();
> >
> > colorbar(-1, 1);
> > grayplot(1:nrows, 1:ncols, dat);
> > e=gce();e.data_mapping="direct";//no interpolation
> >
> > figure2.color_map = jetcolormap(32);
> >
> > a.y_label.text = "Impacted Group";
> > a.y_label.font_size = 4;
> > a.x_label.text = "Impacting Group";
> > a.x_label.font_size = 4;
> > a.title.text = "Relative MTI";
> > a.title.font_size = 5;
> > a.font_size = 4;
> > a.data_bounds = [1, 6, 1, 6];
> >
> > a.x_ticks = tlist(["ticks", "locations", "labels"], (1.5:1:5.5), ["Plants", "Bacteria", "Det. Feeders", "Carnivores", "Detritus"]);
> > a.y_ticks = tlist(["ticks", "locations", "labels"], (1.5:1:5.5), ["Plants", "Bacteria", "Det. Feeders", "Carnivores", "Detritus"]);
> >
> >
> > endfunction
> >
> > _______________________________________________
> > users mailing list
> > users at lists.scilab.org
> > http://lists.scilab.org/mailman/listinfo/users
> 
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
>




More information about the users mailing list