[Scilab-users] grayplot

Rafael Guerra jrafaelbguerra at hotmail.com
Fri Oct 28 02:54:53 CEST 2016


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:

/////// 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([],[],rect=rect, axesflag=1)
f = gcf();
f.color_map = jetcolormap(nc);
addcolor(name2rgb('grey70')/255);
xgrid(65); // a better grid style:
a = gca();
a.grid_style=[8 8];

// 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);   // first xfarcs is  not enough
xfarcs(dots, c);   // Need to repeat it to plot all data...
colorbar(zm,zM);
/////// END OF CODE

Rgds,
Rafael

-----Original Message-----
From: users [mailto:users-bounces at lists.scilab.org] On Behalf Of Samuel Gougeon
Sent: Friday, October 28, 2016 1:35 AM
To: Users mailing list for Scilab <users at lists.scilab.org>
Subject: Re: [Scilab-users] grayplot

Le 27/10/2016 21:56, Rafael Guerra a écrit :
> 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...
.
colorbar(..) creates a new axes. So if you move xfarcs() after colorbar()...
Just set the colorbar() at the end. Then it's ok.
BTW,

// plotframe(rect)  // currently is issuing error message
  plot2d(x,y,rect)
xgrid();
p = get("hdl");
p.children.line_mode="off";

// may be replace with
plot2d([],[],rect=rect, axesflag=1)
   // a better grid style:
xgrid(color("grey70"))
a = gca();
a.grid_style=[8 8];

// IMO this grid style could become the default. Full black is too saturated, and the better linestyle=8 was created quite recently. So the default grid style would deserve being upgraded.
Your opinion?

BR




More information about the users mailing list