[scilab-Users] Re : [scilab-Users] Re : [scilab-Users] Re : [scilab-Users] grayplot scaling

Stephane Mottelet stephane.mottelet at utc.fr
Tue Nov 9 20:23:17 CET 2010


Hi,

you can also use the plotlib 0.21 (the last version working
with Scilab 4 branch) and Scilab 4.2.1. I did
not propose this solution because versions <= 0.4 do not
completely respect the straight Matlab syntax. However,
your example should work written like this (issue the caxis
command before plotting) :

figure,
x = linspace(0,1,101);
z = cos(2*%pi*x)'*sin(2*%pi*x);
zm = min(min(z)); zM = max(max(z));
caxis([zm zM]);
pcolor(x,x,z);
shading flat,
colorbar

figure,
z2 = x'*x*0.4;
caxis([zm zM]);
pcolor(x,x,z2), shading flat,
colorbar

S.

Bouchra Bensiali <bouchra.bensiali at yahoo.fr> a écrit :

> Thank you, it works!
>
> So if I summarize the different solutions :
>
> - use of Sgrayplot with the zminmax option
> http://bugzilla.scilab.org/show_bug.cgi?id=4808#c1
> - use of Matlab syntax with the caxis command and the "Matlab-like" Plotting
> library for Scilab http://atoms.scilab.org/toolboxes/plotlib/0.42  
> (doesn't work
> for me because I have problems when plotting graphics with scilab-5.2.2...)
> - rescaling of data  
> http://bugzilla.scilab.org/show_bug.cgi?id=4808#c3 (doesn't
> work for me, I surely missed something...)
> - use of contourf with color levels
>
> Thanks.
>
>
> ----- Message d'origine ----
> De : Antoine Monmayrant <antoine.monmayrant at laas.fr>
> À : users at lists.scilab.org
> Envoyé le : Mar 9 novembre 2010, 9h 54min 44s
> Objet : Re: [scilab-Users] Re : [scilab-Users] Re : [scilab-Users] grayplot
> scaling
>
> Le 08/11/2010 21:55, Bouchra Bensiali a écrit :
>> Hello and thank you for your answers.
>>
>> Yes, the context is to use a common color scale among several images, excuse
> it
>> wasn't clear in my first message.
> As promised yesterday, here is short example on how I do it using contourf:
>
> ///////////////////////////////////////////////////////////////////////////////////////////
>
> y=linspace(-10,10,100);
> x=linspace(-15,15,200)';
>
> //two 2D maps with different max/min
> z1=cos(x*y/10);
> z2=0.5*cos(x*y/10);
>
> //# of colors to use
> n_color=128;
> // max and min of the color scale
> zmin=-1.1;
> zmax=1.1;
> // levels of the color scale
> color_levels=linspace(zmin,zmax,n_color);
>
>
> h=scf();
> h.color_map=hotcolormap(n_color);
> subplot(121)
> contourf(x,y,z1,color_levels);
> subplot(122)
> contourf(x,y,z2,color_levels);
> colorbar(zmin,zmax);
> ///////////////////////////////////////////////////////////////////////////////////////////
>
>
> I know that colorbar is screwing my layout, but I usually don't use it.
> I prefer plotting a dummy 1xn_color map with custom axis and layout.
> Hope it helps,
>
> Antoine
>
>
>>   And another use would be for animation, as
>> said in the bugzilla link, "zminmax option is important for  
>> animation to have
> a
>> colorbar scale which is not changing from frame to frame".
>>
>> I tried the following:
>> --
>> x = linspace(0,1,101);
>> z = cos(2*%pi*x)'*sin(2*%pi*x);
>> zm = min(z); zM = max(z);
>> xset("window",1)
>> xset("colormap",jetcolormap(64))
>> colorbar(zm,zM)
>> grayplot(x,x,z)
>>
>> z2 = x'*x*0.4;
>> xset("window",2)
>> xset("colormap",jetcolormap(64))
>> colorbar(zm,zM)
>> grayplot(x,x,z2)
>>
>> e = gce(); m = e.data.z;
>> e.data.z = zm+(m-min(m))/(max(m)-min(m))*(zM-zm);
>> --
>> but it doesn't work for me, am I doing something wrong?
>>
>> Thanks.
>>
>>
>>
>> ----- Message d'origine ----
>> De : Samuel GOUGEON<Samuel.Gougeon at univ-lemans.fr>
>> À : users at lists.scilab.org
>> Envoyé le : Lun 8 novembre 2010, 19h 14min 13s
>> Objet : [scilab-Users] Re : [scilab-Users] grayplot scaling
>>
>> ----- Message d'origine -----
>> De : Stéphane Mottelet
>> Date : 08/11/2010 18:23:
>>> What is requested by Bouchra is as intuitive as wanting to change  
>>> axis limits
>>> to easily compare two plots. This feature (caxis stuff) is really  
>>> missing in
>>> Scilab graphics.
>>>
>>> S.
>> For instance to use and share the same colorbar for several plots?
>> Would the following be a work-around?
>> http://bugzilla.scilab.org/show_bug.cgi?id=4808#c3
>>
>>
>>
>>
>
>
> --
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
>   Antoine Monmayrant LAAS - CNRS
>   7 avenue du Colonel Roche
>   31077 TOULOUSE
>   Cedex 4 FRANCE
>
>   Tel:+33 5 61 33 64 59
>
>   email : antoine.monmayrant at laas.fr
>   permanent email : antoine.monmayrant at polytechnique.org
>
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
>
>
>





More information about the users mailing list