[Scilab-users] Colorbar_same color code, different graphs

Antoine Monmayrant antoine.monmayrant at laas.fr
Tue Jul 23 13:42:26 CEST 2013


On 23/07/2013 12:59, Larissa Schultze wrote:
> Hello Samuel and to all,
> thank you, Samuel, for the hint!
> I have now an idea on how to proceed using this cdata_mapping. The problem is:
> when I use this command, error 144 ("Undefined operation for the given
> operands.") appears. What am I doing wrong this time? Man, It can be pretty
> annoying... :/
Well the error here is that you have 'e=gce' instead of 'e=gce()': e is 
now a function pointer (that is its a new name for function gce) and it 
is not the return value from the function gce();

To go back to your problem, I can give you several solutions and here is 
my favorite one: use 'contourf'.
Here is a sample script:

/////////////////////////////
data=[     %nan     0.     20.     60.     100.    140.    180. 200.;..
      0.      %nan    0.      %nan     %nan     %nan     %nan %nan;..
      5.      %nan    68.     73.     61.     63.     67.     %nan;..
      40.     %nan    17.     9.      10.     12.     17.     %nan;..
      75.     %nan    14.     7.      6.      6.      12.     %nan;..
      110.    %nan    15.     6.      4.      6.      21.     %nan;..
      145.    %nan    21.     28.     26.     20.     34.     %nan;..
      150.    %nan    %nan     %nan     %nan     %nan     %nan %nan];

x=data(1,2:8);
y=data(2:8,1);
z=data(2:8,2:8);
xx = linspace(0,200,200);
yy = linspace(0,150,200);
[xp,yp] = ndgrid(xx,yy);
zp = linear_interpn(xp,yp, x, y, z);
h=scf(0);
clf(0)

//these values are common to all your plots
allzmin=-5;//or 6 if you want
allzmax=130;// or 1300 if you want
ncolors=128;//number of colorsteps

contourf(xx,yy,zp,linspace(allzmin,allzmax,ncolors));
a=gca();
a.data_bounds=[min(x),min(y);max(x),max(y)];
a.zoom_box=[min(x),min(y),max(x),max(y)];
h.color_map=jetcolormap(ncolors);
colorbar(allzmin,allzmax);
/////////////////////////////

Alternatively, you can use Sgrayplot with a colormap as large as the 
span of values of z across all the plots and for each plot use only a 
subset of the colormap:

///////////////////////////////////////
ncolors=1300;
h=scf();
h.color_map=jetcolormap(ncolors);
Sgrayplot(xx,yy,zp);
e=gce();
e.children.color_range=[min(zp),max(zp)];
colorbar(1,1300);
////////////////////////////////////

Hope it helps,

Antoine

> At surface_properties it says that the cdata_mapping command ist specific to
> fac3d handles. But this fac3d is obsolete. So I tried to plot my graph with the
> plot3d, plot3d1 and surf to see if any of this works, but no, they don't ...i
> keep getting this error mesage 144.
> Here are again the commands I am using:
> [fd,SST,Sheetnames,Sheetpos] = xls_open('E:\LI_messungen_alle.xls');
> Sheets = readxls('E:\LI_messungen_alle.xls');
> typeof(Sheets);
> s1=Sheets(1);
> data=s1.value;
> x=data(1,2:8);
> y=data(2:8,1);
> z=data(2:8,2:8);
> xx = linspace(0,200,200);
> yy = linspace(0,150,200);
> [xp,yp] = ndgrid(xx,yy);
> zp = linear_interpn(xp,yp, x, y, z);
> clf()
> surf(xx,yy,zp)
> e=gce
> e.cdata_mapping='direct'
> e.color_map=jetcolormap(512);
> e.color_flag=2;
> e.data.color=[1+modulo(1:1300,512),1+modulo(1:1300,512)];
> h.color_flag=3;
> colorbar(1,1300)
> And this is, again, my table:
> Nan     0.     20.     60.     100.    140.    180.    200.
>       0.      Nan    0.      Nan     Nan     Nan     Nan     Nan
>       5.      Nan    68.     73.     61.     63.     67.     Nan
>       40.     Nan    17.     9.      10.     12.     17.     Nan
>       75.     Nan    14.     7.      6.      6.      12.     Nan
>       110.    Nan    15.     6.      4.      6.      21.     Nan
>       145.    Nan    21.     28.     26.     20.     34.     Nan
>       150.    Nan    Nan     Nan     Nan     Nan     Nan     Nan
> Do you have any idea of what is wrong?
> Thank you again,
> Larissa
> *Gesendet:* Dienstag, 23. Juli 2013 um 03:37 Uhr
> *Von:* "Samuel Gougeon" <sgougeon at free.fr>
> *An:* "International users mailing list for Scilab." <users at lists.scilab.org>
> *Betreff:* Re: [Scilab-users] Colorbar_same color code, different graphs
> Hello Larissa,
>
> After surf(..), you may do
> e = gce();
> e.cdata_mapping = 'direct';
> // and have a look at
> help "surface properties"
>
> HTH
> Samuel
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
>
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20130723/437d3a53/attachment.htm>


More information about the users mailing list