[Scilab-users] grayplot

Samuel Gougeon sgougeon at free.fr
Fri Oct 28 03:15:54 CEST 2016


Le 28/10/2016 02:54, Rafael Guerra a écrit :
> Samuel,
>
> The proposed grid looks much better than Scilab's default.
>
> Regarding the tip to move the colorbar command to the end of the code, code still behaves in unstable way...
> Please see revised code here below where the issue strikes back:
.
With the grid between xfarcs() and the colorbar(), it works.
BTW, wherever a new color is used, it is automatically appended to the 
colormap: no need to append it by hand:

> /////// START OF CODE
> clf();
> x=[8030 8040 7998 8008 8037 7956 7937 7963 7919 7920];
> y=[9478 9533 9578 9590 9597 9626 9627 9723 9766 9768];
> z=[-2.39965177 1.81709373 -1.14068067 -2.95249772 -3.25881290 1.36802530 -1.46287727 ...
>      -6.40911865 1.03929353 1.49115121];
>
> xm = min(x); xM = min(x); dx = strange(x);
> ym = min(y); yM = min(y); dy = strange(y);
> zm = min(z); zM = max(z);
>
> xtitle("Color coded scatter data under Scilab 5x")
> mg = 0.05; // plot area relative margin
> nc = 64; // number of colors
> rect = [xm,ym,xM,yM] + mg*[-dx,-dy,dx,dy];
> // plotframe(rect)  // currently is issuing error message
> plot2d([],[],rect=rect, axesflag=1)
> f = gcf();
> f.color_map = jetcolormap(nc);
>
> // shaping dots (by S.Gougeon)
> ar = f.axes_size; ar = ar(1)/ar(2); // w/h aspect ratio of figure
> dotsize_r = 0.04;   // relative size of dots
> h = dy*dotsize_r;
> w = dx*dotsize_r/ar;
> dots = [x-w/2; y+h/2; ones(x)*w; ones(x)*h; zeros(x); ones(x)*64*360];
> c = round(1+(z-zm)*(nc-1)/(zM-zm)); // dots colors scaled against z-value
> xfarcs(dots, c);
>
> xgrid(color("grey70")); // a better grid style:
> a = gca();
> a.grid_style=[8 8];
>
> colorbar(zm,zM,[1 nc]);
> /////// END OF CODE
>




More information about the users mailing list