[Scilab-users] grayplot

Rafael Guerra jrafaelbguerra at hotmail.com
Thu Oct 27 21:56:55 CEST 2016


Hi again,

After tidying up Nec's code a bit further and applying Samuel's xfarcs receipe for colored scatter plots in Scilab 5x, I encountered the following strange behavior. For some reason, in the code here below, xfarcs has to be called twice in order to display properly all the data...

/////// START OF CODE
clf();
clear;
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(x,y,rect)
xgrid();
p = get("hdl");
p.children.line_mode="off";
f = gcf();
f.color_map = jetcolormap(nc);
colorbar(zm,zM);

// 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);   // plotting dots (the first time does not work well!?)
xfarcs(dots, c);   // second time seems to be Ok...
/////// END OF CODE

Why?

Rgds,
Rafael


From: users [mailto:users-bounces at lists.scilab.org] On Behalf Of Samuel Gougeon
Sent: Thursday, October 27, 2016 8:15 PM
To: Users mailing list for Scilab <users at lists.scilab.org>
Subject: Re: [Scilab-users] grayplot

Le 27/10/2016 18:50, Rafael Guerra a écrit :
Hi Samuel,

Scilab-6  'scatter' plot function seems indeed quite adequate for these data.
Would it be possible to produce such scatter plots with dots color coded (as attached) in Scilab 5?
.
yes it is, for instance using xfarcs() as below.
Regards
np = 40;    // number of points
x = grand(1,np, "unf", -20, 140);
y = grand(1,np, "unf", -50, 300);
dz = 6.4;
z = grand(1,np, "unf", -dz, dz);

clf
f = gcf();
nc = 100;
f.color_map = jetcolormap(nc);
plotframe([-20 -50 140 300])
c = round((z+dz)/(2*dz)*(nc-1)+1); // colors of dots scaled against their z
// shaping dots
ar = f.axes_size; ar = ar(1)/ar(2); // w/h aspect ratio of figure
dotsize_r = 0.04;   // relative size of dots
h = strange(y)*dotsize_r;
w = strange(x)*dotsize_r/ar;
dots = [x ; y ; ones(x)*w ; ones(x)*h ; zeros(x) ; ones(x)*64*360];
// plotting dots
xfarcs(dots, c);
// colorbar
colorbar(-dz,dz)




More information about the users mailing list