colorbar.sci function is wrong in drawing the bar: fec() has changed from 4.1.2 to 5.x
Reported by l.desimio
colorbar_ERROR.bmp (1.09 MB, image/bmp)
A minor space was associated with the first and last color.
BUG DESCRIPTION:
----------------
The colorbar.sci function is wrong in drawing the bar. A minor space was associated with the first and last color.
See the red and blue color of the bar in the following figure.
The image was obtaine with:
// example 1
x = linspace(0,1,81);
z = cos(2*%pi*x)'*sin(2*%pi*x);
zm = min(z); zM = max(z);
clf()
xset("colormap",jetcolormap(4))
colorbar(zm,zM)
Sgrayplot(x,x,z)
xtitle("The function cos(2 pi x)sin(2 pi y)")
ERROR LOG:
----------
HOW TO REPRODUCE THE BUG:
-------------------------
// example 1
x = linspace(0,1,81);
z = cos(2*%pi*x)'*sin(2*%pi*x);
zm = min(z); zM = max(z);
clf()
xset("colormap",jetcolormap(4))
colorbar(zm,zM)
Sgrayplot(x,x,z)
xtitle("The function cos(2 pi x)sin(2 pi y)")
OTHER INFORMATION:
------------------
The error is present from version 5.2.1. The error is also present in the latest version, 6.0.
In version 4.2.1 the error was not prensent.
Comparing the colorbar.sci files of the different versions I realized that part of the code is not performed when we have moved from the "figure style old" (Scilab version 4.2.1) to the "Figure style new".
The code not executed seems to be the following:
// go on...
vec_ones = ones(1,nb_colors)
x1 = -0.3 ; x2 = 0.1 ;
x_polys = [x1 ; x2 ; x2 ; x1] * vec_ones
y1 = 0.1 ; y2 = 0.9
y = linspace(y1,y2,nb_colors+1)
y_polys = [y(1:$-1) ; y(1:$-1) ; y(2:$) ; y(2:$)]
xtics = x2*ones(1,nb_grad) ; dx_tics = 0.05 ;
ytics = linspace(y1, y2, nb_grad) ; dy_tics = 0
valeurs = linspace(umin,umax,nb_grad);
rect = xstringl(0, 0, string(umin))
dy_cor = -rect(4)*0.5
xmarks = xtics + 3*dx_tics ; ymarks = ytics + dy_cor;
fg_color = xget("foreground")
wr = xgetech()
wrect_cb = [wr(1)+0.85*wr(3) , wr(2) , 0.15*wr(3) , wr(4)]
wrect_pl = [wr(1) , wr(2) , 0.85*wr(3) , wr(4)]
xsetech(wrect=wrect_cb,frect=[0 0 1 1], arect=0.125*[1 1 1 1])
xfpolys(x_polys, y_polys, -(colminmax(1):colminmax(2)))
xset("color", fg_color) ;
xpoly([x1 x2 x2 x1],[y1 y1 y2 y2],"lines",1)
lab=msprintf(fmt+'\n',valeurs(:))
for k=1:size(xmarks,'*')
xstring(xmarks(k), ymarks(k) ,lab(k))
end
xsegs([xtics ; xtics+dx_tics ],[ytics ; ytics+dy_tics],fg_color)
xsetech(wrect=wrect_pl)