Integrating SciLab and EPANET (.dll written in C/C++)

classic Classic list List threaded Threaded
17 messages Options
Chuox Chuox
Reply | Threaded
Open this post in threaded view
|

Integrating SciLab and EPANET (.dll written in C/C++)

This post was updated on .
Hi im trying to integrate EPANET and SciLab, i all ready do it in MATLAB, (i actually din't do it Demetrios Eliades did it) i'm going to show how i succesfull did it in MATLAB, and then how i'm trying to do it in SciLab.

I download the EPANET toolkit

In MATLAB



>> loadlibrary('epanet2', 'epanet2.h')

>> [errorcode] = calllib('epanet2', 'ENopen', 'Net1.inp', 'temp1.$$$', 'temp2.$$$')

errorcode =

     0

>> index=1;
diam=0;
[error,diam] =calllib('epanet2', 'ENgetlinkvalue', index, 0, diam)

error =

     0


diam =

    18

End Working in MATLAB


In SciLab


-->link("C:\Users\Alfredo\Google Drive\Tesis\SciLab\epanet2.dll","ENopen","c")
Shared archive loaded.
Link done.
 ans  =
 
    0.

-->c_link("ENopen")
 ans  =
 
  T  

-->call("ENopen","C:\Users\Alfredo\Google Drive\Tesis\SciLab\Net1.inp","temp1.$$$","temp2.$$$")
Warning !!!
Scilab has found a critical error (EXCEPTION_ACCESS_VIOLATION)
with "call" function.
Save your data and restart Scilab.
 ans  =
 
 temp2.$$$  
 
Warning: stack problem..., cleared.

End working in SciLab


I think in not using very well the call function, any help will be apreciated, thanks.
Antoine Monmayrant Antoine Monmayrant
Reply | Threaded
Open this post in threaded view
|

Re: Integrating SciLab and EPANET (.dll written in C/C++)

On 05/07/2013 20:45, Chuox wrote:
> Hi im trying to integrate EPANET and SciLab, i all ready do it in MATLAB, (i
> actually din't do it  Demetrios Eliades
> <http://www.mathworks.com/matlabcentral/fileexchange/authors/53840>   i'm
> going to show how i succesfull did it in MATLAB, and then how i'm trying to
> do it in SciLab.
>
> In MATLAB

Hi,

It does seem that you are not using "call" properly.
Have a look at the examples in Scilab Help >> Link dynamique/incremental
 > call
You basically need to know and tell "call", for each input argument:
- its position in the function call: ret=function(a,b,c): a: position 1,
b: position 2,c: position 3.
- its type and dimension.
You also have to do the same for the output argument.

If you give us the prototype of the C function you are trying to call,
we might try to get the right call sequence.

Cheers,

Antoine

>
>
>
>>> loadlibrary('epanet2', 'epanet2.h')
>>> [errorcode] = calllib('epanet2', 'ENopen', 'Net1.inp', 'temp1.$$$',
>>> 'temp2.$$$')
> errorcode =
>
>       0
>
>>> index=1;
> diam=0;
> [error,diam] =calllib('epanet2', 'ENgetlinkvalue', index, 0, diam)
>
> error =
>
>       0
>
>
> diam =
>
>      18
>
> End Working in MATLAB
>
>
> In SciLab
>
>
> -->link("C:\Users\Alfredo\Google
> Drive\Tesis\SciLab\epanet2.dll","ENopen","c")
> Shared archive loaded.
> Link done.
>   ans  =
>  
>      0.
>
> -->c_link("ENopen")
>   ans  =
>  
>    T
>
> -->call("ENopen","C:\Users\Alfredo\Google
> Drive\Tesis\SciLab\Net1.inp","temp1.$$$","temp2.$$$")
> Warning !!!
> Scilab has found a critical error (EXCEPTION_ACCESS_VIOLATION)
> with "call" function.
> Save your data and restart Scilab.
>   ans  =
>  
>   temp2.$$$
>  
> Warning: stack problem..., cleared.
>
> En working in SciLab
>
>
> I think in not using very well the call function, any help will be
> apreciated, thanks.
>
>
>
> --
> View this message in context: http://mailinglists.scilab.org/Integrating-SciLab-and-EPANET-dll-written-in-C-C-tp4026977.html
> Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com.
> _______________________________________________
> users mailing list
> [hidden email]
> http://lists.scilab.org/mailman/listinfo/users


--
+++++++++++++++++++++++++++++++++++++++++++++++++++++++

  Antoine Monmayrant LAAS - CNRS
  7 avenue du Colonel Roche
  BP 54200
  31031 TOULOUSE Cedex 4
  FRANCE

  Tel:+33 5 61 33 64 59
 
  email : [hidden email]
  permanent email : [hidden email]

+++++++++++++++++++++++++++++++++++++++++++++++++++++++

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Chuox Chuox
Reply | Threaded
Open this post in threaded view
|

Re: Integrating SciLab and EPANET (.dll written in C/C++)

This post was updated on .
And how can i know the position in the function? its inside a .dll, here is the epanet2.dll and the header epanet2.h

I understood a lite more about the call function reading this  "introduction to SciLab", then i change the SciLab Code, the result should be an error code, in this case "0= no error", all a got is a C, i have no idea were it came from.

-->call("ENopen","C:\<path>\Net1.inp",1,"c","temp1.$$$",2,"c","temp2.$$$",3,"c","out",[1,1],1,"c")
 ans  =
 
 C  
Chuox Chuox
Reply | Threaded
Open this post in threaded view
|

Re: Integrating SciLab and EPANET (.dll written in C/C++)

In reply to this post by Antoine Monmayrant
Cheers! I found this in the EPANET toolkit help:

An example of using these functions is shown below.

char *f1,  /* Name of input file */
     *f2,  /* name of report file */
     *f3;  /* name of output file (can be blank) */
int  errcode;
errcode = ENopen(f1, f2, f3);
if (errcode > 0) {
  ENclose();
  return;
}
{ Call functions that perform desired analysis }
ENclose()

So... the correct use of the ENopen function should be something like this:

errorcode=call("ENopen","C:\Users\Alfredo\Google Drive\Tesis\SciLab\Net1.inp",1,"c","temp1.$$$",2,"c","",3,"c","out",[1,1],4,"i")

 errorcode  = 1

It Should be  errorcode  = 0 , so maybe im still doing something wrong.
Larissa Larissa
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] Colorbar_same color code, different graphs

Hello everyone,
 
I have to plot several graphs with measurements ranging from 6 to 1300. I would like that these graphs obey the same color code, so that, in the example of jetcolormap, "1300" would always be dark red and "0" would always be dark blue for each graph. Now the values that I have for the different graphs are quite diverse: graph 1 has values ranging between "6" and "68" whereas graph 6 has values between "600" and "1300".
 
How can I manage that the colorbar and the colorcode for both these graphs remains the same? (in this case, graph 1 would presumably have only a gradient of dark blue colors and graph 6 would have rather orange to red colors)
I tried changing the command of colorbar to "colorbar(0,1300)", but it didn't work at all...so I thought may be someone could give me a hint on how I would be able to align the color code these graphs...
 
Thank you guys in advance!!!!
Larissa
 
 
 
 
 
 
 
Gesendet: Freitag, 12. Juli 2013 um 04:56 Uhr
Von: Chuox <[hidden email]>
An: [hidden email]
Betreff: Re: [Scilab-users] Integrating SciLab and EPANET (.dll written in C/C++)
Cheers! I found this in the EPANET toolkit help:

An example of using these functions is shown below.

char *f1, /* Name of input file */
*f2, /* name of report file */
*f3; /* name of output file (can be blank) */
int errcode;
errcode = ENopen(f1, f2, f3);
if (errcode > 0) {
ENclose();
return;
}
{ Call functions that perform desired analysis }
ENclose()

So... the correct use of the ENopen function should be something like this:

errorcode=call("ENopen","C:\Users\Alfredo\Google
Drive\Tesis\SciLab\Net1.inp",1,"c","temp1.$$$",2,"c","",3,"c","out",[1,1],4,"i")

errorcode = 1

It Should be errorcode = 0 , so maybe im still doing something wrong.




--
View this message in context: http://mailinglists.scilab.org/Integrating-SciLab-and-EPANET-dll-written-in-C-C-tp4026977p4027020.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com.
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Larissa Larissa
Reply | Threaded
Open this post in threaded view
|

Re: Colorbar_same color code, different graphs

Hello everyone,
 
I have to plot several graphs with measurements ranging from 6 to 1300. I would like that these graphs obey the same color code, so that, in the example of jetcolormap, "1300" would always be dark red and "0" would always be dark blue for each graph. Now the values that I have for the different graphs are quite diverse: graph 1 has values ranging between "6" and "68" whereas graph 6 has values between "600" and "1300".
 
How can I manage that the colorbar and the colorcode for both these graphs remains the same? (in this case, graph 1 would presumably have only a gradient of dark blue colors and graph 6 would have rather orange to red colors)
I tried changing the command of colorbar to "colorbar(0,1300)", but it didn't work at all...so I thought may be someone could give me a hint on how I would be able to align the color code these graphs...
 
I put an example of my tables on the annex as well as the scilab commands that I have been using for that. I simply need the values of both tables to be registered according to one color code (1300=dark red, 6=dark blue)...I would appreciate it a lot if someone could help me. :) 
 
Thank you guys in advance!!!!
Larissa
 

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users

example_colorbarproblem_notes.txt (1007 bytes) Download Attachment
example_colorbarproblem.xlsx (12K) Download Attachment
Mike Page Mike Page
Reply | Threaded
Open this post in threaded view
|

Re: Colorbar_same color code, different graphs


Hi Larissa,
 
I'm no expert on this, but have you tried changing the data_bounds for the figure's children independently?  I think if you just set the colorbar limits with colorbar(a,b), that only changes the legend on the bar itself.
 
Try f=gcf(); then look at f.children(1),data_bounds or f.children(2).data_bounds.  I think one will be for the plot and the other for the colorbar.  If you change these limits directly you may get the effect you are looking for.
 
Sorry if I misunderstood your question.
 
Mike.
 
-----Original Message-----
From: [hidden email] [mailto:[hidden email]]On Behalf Of Larissa Schultze
Sent: 16 July 2013 08:48
To: International users mailing list for Scilab.
Subject: Re: [Scilab-users] Colorbar_same color code, different graphs

Hello everyone,
 
I have to plot several graphs with measurements ranging from 6 to 1300. I would like that these graphs obey the same color code, so that, in the example of jetcolormap, "1300" would always be dark red and "0" would always be dark blue for each graph. Now the values that I have for the different graphs are quite diverse: graph 1 has values ranging between "6" and "68" whereas graph 6 has values between "600" and "1300".
 
How can I manage that the colorbar and the colorcode for both these graphs remains the same? (in this case, graph 1 would presumably have only a gradient of dark blue colors and graph 6 would have rather orange to red colors)
I tried changing the command of colorbar to "colorbar(0,1300)", but it didn't work at all...so I thought may be someone could give me a hint on how I would be able to align the color code these graphs...
 
I put an example of my tables on the annex as well as the scilab commands that I have been using for that. I simply need the values of both tables to be registered according to one color code (1300=dark red, 6=dark blue)...I would appreciate it a lot if someone could help me. :) 
 
Thank you guys in advance!!!!
Larissa
 

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Larissa Larissa
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] Colorbar_same color code, different graphs

Hi everybody,
 
thank you a lot for your reply, Mike.
The suggestion sounds really good, but I couldn't make it work yet, unfortunately.
So again, for the 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 

I used the following commands:
 
"
[fd,SST,Sheetnames,Sheetpos] = xls_open('E:\XXXXXX.xls')
Sheets = readxls('E:\XXXXXXX.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);
f=get("current_figure");
f.color_map=jetcolormap(512);
h=get("hdl") //get handle on current entity (here the surface)
h.color_flag=1;
a=gca();
a.auto_scale="off";
a.tight_limits="on";
a.data_bounds=[0,0,0;200,150,1300]
colorbar(0,1300);
"
 
Still, the colors in the figure do not correspond to those of the colorbar. I mean, according to the colorbar, this dataset should have basically different dark blue tones...and that is what I am aiming at. ...but...how can I possibly make it work? Can anybody help me please?
It would be great!!!!
 
thank you in advance and kind regards,
Larissa
 
 
 
 
 
 
 
Gesendet: Dienstag, 16. Juli 2013 um 11:09 Uhr
Von: "Mike Page" <[hidden email]>
An: "International users mailing list for Scilab." <[hidden email]>
Betreff: Re: [Scilab-users] Colorbar_same color code, different graphs
Hi Larissa,
 
I'm no expert on this, but have you tried changing the data_bounds for the figure's children independently?  I think if you just set the colorbar limits with colorbar(a,b), that only changes the legend on the bar itself.
 
Try f=gcf(); then look at f.children(1),data_bounds or f.children(2).data_bounds.  I think one will be for the plot and the other for the colorbar.  If you change these limits directly you may get the effect you are looking for.
 
Sorry if I misunderstood your question.
 
Mike.
 
-----Original Message-----
From: [hidden email] [mailto:[hidden email]]On Behalf Of Larissa Schultze
Sent: 16 July 2013 08:48
To: International users mailing list for Scilab.
Subject: Re: [Scilab-users] Colorbar_same color code, different graphs

 
Hello everyone,
 
I have to plot several graphs with measurements ranging from 6 to 1300. I would like that these graphs obey the same color code, so that, in the example of jetcolormap, "1300" would always be dark red and "0" would always be dark blue for each graph. Now the values that I have for the different graphs are quite diverse: graph 1 has values ranging between "6" and "68" whereas graph 6 has values between "600" and "1300".
 
How can I manage that the colorbar and the colorcode for both these graphs remains the same? (in this case, graph 1 would presumably have only a gradient of dark blue colors and graph 6 would have rather orange to red colors)
I tried changing the command of colorbar to "colorbar(0,1300)", but it didn't work at all...so I thought may be someone could give me a hint on how I would be able to align the color code these graphs...
 
I put an example of my tables on the annex as well as the scilab commands that I have been using for that. I simply need the values of both tables to be registered according to one color code (1300=dark red, 6=dark blue)...I would appreciate it a lot if someone could help me. :) 
 
Thank you guys in advance!!!!
Larissa
 

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Mike Page Mike Page
Reply | Threaded
Open this post in threaded view
|

Re: Colorbar_same color code, different graphs


Hi Larissa,
 
Sorry, but I don't know how to do what you want.  As far as I know, when you assign a colormap to a figure, the colors span across the range of the data (so zmax = red and zmin = blue for example).  I think you want them to span across the data bounds of the figure, but I don't know how to do that.
 
The idea I mentioned before will produce a colorbar that spans the right set of colors and has the right legend, but I don't know how to get the colors on the figure right.  I'm sure it can be done some way, but I don't know how.  Perhaps you could add an artificial point to your data to make it span the full range?
 
Mike.
 
-----Original Message-----
From: [hidden email] [mailto:[hidden email]]On Behalf Of Larissa Schultze
Sent: 22 July 2013 13:24
To: [hidden email]
Cc: International users mailing list for Scilab.
Subject: [Scilab-users] Colorbar_same color code, different graphs

Hi everybody,
 
thank you a lot for your reply, Mike.
The suggestion sounds really good, but I couldn't make it work yet, unfortunately.
So again, for the 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 

I used the following commands:
 
"
[fd,SST,Sheetnames,Sheetpos] = xls_open('E:\XXXXXX.xls')
Sheets = readxls('E:\XXXXXXX.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);
f=get("current_figure");
f.color_map=jetcolormap(512);
h=get("hdl") //get handle on current entity (here the surface)
h.color_flag=1;
a=gca();
a.auto_scale="off";
a.tight_limits="on";
a.data_bounds=[0,0,0;200,150,1300]
colorbar(0,1300);
"
 
Still, the colors in the figure do not correspond to those of the colorbar. I mean, according to the colorbar, this dataset should have basically different dark blue tones...and that is what I am aiming at. ...but...how can I possibly make it work? Can anybody help me please?
It would be great!!!!
 
thank you in advance and kind regards,
Larissa
 
 
 
 
 
 
 
Gesendet: Dienstag, 16. Juli 2013 um 11:09 Uhr
Von: "Mike Page" <[hidden email]>
An: "International users mailing list for Scilab." <[hidden email]>
Betreff: Re: [Scilab-users] Colorbar_same color code, different graphs
Hi Larissa,
 
I'm no expert on this, but have you tried changing the data_bounds for the figure's children independently?  I think if you just set the colorbar limits with colorbar(a,b), that only changes the legend on the bar itself.
 
Try f=gcf(); then look at f.children(1),data_bounds or f.children(2).data_bounds.  I think one will be for the plot and the other for the colorbar.  If you change these limits directly you may get the effect you are looking for.
 
Sorry if I misunderstood your question.
 
Mike.
 
-----Original Message-----
From: [hidden email] [mailto:[hidden email]]On Behalf Of Larissa Schultze
Sent: 16 July 2013 08:48
To: International users mailing list for Scilab.
Subject: Re: [Scilab-users] Colorbar_same color code, different graphs

 
Hello everyone,
 
I have to plot several graphs with measurements ranging from 6 to 1300. I would like that these graphs obey the same color code, so that, in the example of jetcolormap, "1300" would always be dark red and "0" would always be dark blue for each graph. Now the values that I have for the different graphs are quite diverse: graph 1 has values ranging between "6" and "68" whereas graph 6 has values between "600" and "1300".
 
How can I manage that the colorbar and the colorcode for both these graphs remains the same? (in this case, graph 1 would presumably have only a gradient of dark blue colors and graph 6 would have rather orange to red colors)
I tried changing the command of colorbar to "colorbar(0,1300)", but it didn't work at all...so I thought may be someone could give me a hint on how I would be able to align the color code these graphs...
 
I put an example of my tables on the annex as well as the scilab commands that I have been using for that. I simply need the values of both tables to be registered according to one color code (1300=dark red, 6=dark blue)...I would appreciate it a lot if someone could help me. :) 
 
Thank you guys in advance!!!!
Larissa
 

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Larissa Larissa
Reply | Threaded
Open this post in threaded view
|

Re: Colorbar_same color code, different graphs

Hi Mike,
 
thanks for your reply.
Yeah, exactly that is the problem - In a previous experiment I had used the "artificial point" trick, but the values I had by then were closer to each other (say, before I had minimum 60 maximum 400; now I have minimum 4 and maximum 1300) than they are now. Thus, by the previous experiment this artificial point wasn't really noticed nor intefering with the data, but now it is, so it can't be ignored unfortunately. 
 
But thank you very much for your effort, Mike :)
May be someone else has an idea or a simple guess on how to proceed? I guess it shouldn't be that difficult...I am running out of ideas though....
 
Thanks a lot,
Larissa
 
 
Gesendet: Montag, 22. Juli 2013 um 18:21 Uhr
Von: "Mike Page" <[hidden email]>
An: "International users mailing list for Scilab." <[hidden email]>
Betreff: Re: [Scilab-users] Colorbar_same color code, different graphs
Hi Larissa,
 
Sorry, but I don't know how to do what you want.  As far as I know, when you assign a colormap to a figure, the colors span across the range of the data (so zmax = red and zmin = blue for example).  I think you want them to span across the data bounds of the figure, but I don't know how to do that.
 
The idea I mentioned before will produce a colorbar that spans the right set of colors and has the right legend, but I don't know how to get the colors on the figure right.  I'm sure it can be done some way, but I don't know how.  Perhaps you could add an artificial point to your data to make it span the full range?
 
Mike.
 
-----Original Message-----
From: [hidden email] [mailto:[hidden email]]On Behalf Of Larissa Schultze
Sent: 22 July 2013 13:24
To: [hidden email]
Cc: International users mailing list for Scilab.
Subject: [Scilab-users] Colorbar_same color code, different graphs

 
Hi everybody,
 
thank you a lot for your reply, Mike.
The suggestion sounds really good, but I couldn't make it work yet, unfortunately.
So again, for the 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 
 
I used the following commands:
 
"
[fd,SST,Sheetnames,Sheetpos] = xls_open('E:\XXXXXX.xls')
Sheets = readxls('E:\XXXXXXX.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);
f=get("current_figure");
f.color_map=jetcolormap(512);
h=get("hdl") //get handle on current entity (here the surface)
h.color_flag=1;
a=gca();
a.auto_scale="off";
a.tight_limits="on";
a.data_bounds=[0,0,0;200,150,1300]
colorbar(0,1300);
"
 
Still, the colors in the figure do not correspond to those of the colorbar. I mean, according to the colorbar, this dataset should have basically different dark blue tones...and that is what I am aiming at. ...but...how can I possibly make it work? Can anybody help me please?
It would be great!!!!
 
thank you in advance and kind regards,
Larissa
 
 
 
 
 
 
 
Gesendet: Dienstag, 16. Juli 2013 um 11:09 Uhr
Von: "Mike Page" <[hidden email]>
An: "International users mailing list for Scilab." <[hidden email]>
Betreff: Re: [Scilab-users] Colorbar_same color code, different graphs
Hi Larissa,
 
I'm no expert on this, but have you tried changing the data_bounds for the figure's children independently?  I think if you just set the colorbar limits with colorbar(a,b), that only changes the legend on the bar itself.
 
Try f=gcf(); then look at f.children(1),data_bounds or f.children(2).data_bounds.  I think one will be for the plot and the other for the colorbar.  If you change these limits directly you may get the effect you are looking for.
 
Sorry if I misunderstood your question.
 
Mike.
 
-----Original Message-----
From: [hidden email] [mailto:[hidden email]]On Behalf Of Larissa Schultze
Sent: 16 July 2013 08:48
To: International users mailing list for Scilab.
Subject: Re: [Scilab-users] Colorbar_same color code, different graphs

 
Hello everyone,
 
I have to plot several graphs with measurements ranging from 6 to 1300. I would like that these graphs obey the same color code, so that, in the example of jetcolormap, "1300" would always be dark red and "0" would always be dark blue for each graph. Now the values that I have for the different graphs are quite diverse: graph 1 has values ranging between "6" and "68" whereas graph 6 has values between "600" and "1300".
 
How can I manage that the colorbar and the colorcode for both these graphs remains the same? (in this case, graph 1 would presumably have only a gradient of dark blue colors and graph 6 would have rather orange to red colors)
I tried changing the command of colorbar to "colorbar(0,1300)", but it didn't work at all...so I thought may be someone could give me a hint on how I would be able to align the color code these graphs...
 
I put an example of my tables on the annex as well as the scilab commands that I have been using for that. I simply need the values of both tables to be registered according to one color code (1300=dark red, 6=dark blue)...I would appreciate it a lot if someone could help me. :) 
 
Thank you guys in advance!!!!
Larissa
 

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
windkraft windkraft
Reply | Threaded
Open this post in threaded view
|

Re: Colorbar_same color code, different graphs

In reply to this post by Larissa
Hallo Larissa

Mikes Vorschlag ist auch bei einem großen Datenbereich gut.
Brauchst Du in Deinen Darstellungen unbedingt die absoluten Größen?
Falls nicht, normiere die Werte und nimm die künstlichen Punkte
jeweils deutlich außerhalb des dann vorliegenden x% - 100% Intervalls.
Zu Gedränge kommt es trotzdem

2013/7/22 Larissa Schultze <[hidden email]>:

> Hi everybody,
>
> thank you a lot for your reply, Mike.
> The suggestion sounds really good, but I couldn't make it work yet,
> unfortunately.
> So again, for the 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
>
> I used the following commands:
>
> "
> [fd,SST,Sheetnames,Sheetpos] = xls_open('E:\XXXXXX.xls')
> Sheets = readxls('E:\XXXXXXX.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);
> f=get("current_figure");
> f.color_map=jetcolormap(512);
> h=get("hdl") //get handle on current entity (here the surface)
> h.color_flag=1;
> a=gca();
> a.auto_scale="off";
> a.tight_limits="on";
> a.data_bounds=[0,0,0;200,150,1300]
> colorbar(0,1300);
> "
>
> Still, the colors in the figure do not correspond to those of the colorbar.
> I mean, according to the colorbar, this dataset should have basically
> different dark blue tones...and that is what I am aiming at. ...but...how
> can I possibly make it work? Can anybody help me please?
> It would be great!!!!
>
> thank you in advance and kind regards,
> Larissa
>
>
>
>
>
>
>
> Gesendet: Dienstag, 16. Juli 2013 um 11:09 Uhr
> Von: "Mike Page" <[hidden email]>
> An: "International users mailing list for Scilab." <[hidden email]>
> Betreff: Re: [Scilab-users] Colorbar_same color code, different graphs
> Hi Larissa,
>
> I'm no expert on this, but have you tried changing the data_bounds for the
> figure's children independently?  I think if you just set the colorbar
> limits with colorbar(a,b), that only changes the legend on the bar itself.
>
> Try f=gcf(); then look at f.children(1),data_bounds or
> f.children(2).data_bounds.  I think one will be for the plot and the other
> for the colorbar.  If you change these limits directly you may get the
> effect you are looking for.
>
> Sorry if I misunderstood your question.
>
> Mike.
>
>
> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]]On Behalf Of Larissa Schultze
> Sent: 16 July 2013 08:48
> To: International users mailing list for Scilab.
> Subject: Re: [Scilab-users] Colorbar_same color code, different graphs
>
> Hello everyone,
>
> I have to plot several graphs with measurements ranging from 6 to 1300. I
> would like that these graphs obey the same color code, so that, in the
> example of jetcolormap, "1300" would always be dark red and "0" would always
> be dark blue for each graph. Now the values that I have for the different
> graphs are quite diverse: graph 1 has values ranging between "6" and "68"
> whereas graph 6 has values between "600" and "1300".
>
> How can I manage that the colorbar and the colorcode for both these graphs
> remains the same? (in this case, graph 1 would presumably have only a
> gradient of dark blue colors and graph 6 would have rather orange to red
> colors)
> I tried changing the command of colorbar to "colorbar(0,1300)", but it
> didn't work at all...so I thought may be someone could give me a hint on how
> I would be able to align the color code these graphs...
>
> I put an example of my tables on the annex as well as the scilab commands
> that I have been using for that. I simply need the values of both tables to
> be registered according to one color code (1300=dark red, 6=dark blue)...I
> would appreciate it a lot if someone could help me. :)
>
> Thank you guys in advance!!!!
> Larissa
>
>
>
> _______________________________________________
> users mailing list
> [hidden email]
> http://lists.scilab.org/mailman/listinfo/users
>
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Samuel GOUGEON Samuel GOUGEON
Reply | Threaded
Open this post in threaded view
|

Re: Colorbar_same color code, different graphs

In reply to this post by Larissa
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
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Larissa Larissa
Reply | Threaded
Open this post in threaded view
|

Re: Colorbar_same color code, different graphs

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... :/
 
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" <[hidden email]>
An: "International users mailing list for Scilab." <[hidden email]>
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
[hidden email]
http://lists.scilab.org/mailman/listinfo/users

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Christophe Dang Ngoc Chan Christophe Dang Ngoc Chan
Reply | Threaded
Open this post in threaded view
|

Re: Colorbar_same color code, different graphs

Hello,

> De la part de Larissa Schultze
> Envoyé : mardi 23 juillet 2013 12:59
>
> At surface_properties it says that the cdata_mapping command ist
> specific to fac3d handles. But this fac3d is obsolete.

Fac3d is a (obsolete) Scilab primitive, but is is also a class of
graphic entities.

Read the beginning of the
http://help.scilab.org/docs/5.4.1/en_US/surface_properties.html
help page :
"Two classes appears under this type of entity : Plot3d and Fac3d
according to the plotting function or the way data is entered. Fac3d and
Plo3d entities are similar but Fac3d is more complete [...]."

Best regards.

--
Christophe Dang Ngoc Chan
Mechanical calculation engineer

______________________________________________________________________

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error), please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
______________________________________________________________________
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Larissa Larissa
Reply | Threaded
Open this post in threaded view
|

Re: Colorbar_same color code, different graphs

Hello Christophe,
 
well, I had tried that too actually, but error 144 appears even if it use genfac3d before...here is what I had tried already:
 
[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()
[xa,ya,za]=genfac3d(xx,yy,zp);
plot3d(xa,ya,za)
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)
 
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 
 
 
So I assume that there must be something missing/wrong somewhere else?
 
Thanks a lot,
Larissa
 
 
 
 
 
 
 
Gesendet: Dienstag, 23. Juli 2013 um 13:24 Uhr
Von: "Dang, Christophe" <[hidden email]>
An: "International users mailing list for Scilab." <[hidden email]>
Betreff: Re: [Scilab-users] Colorbar_same color code, different graphs
Hello,

> De la part de Larissa Schultze
> Envoyé : mardi 23 juillet 2013 12:59
>
> At surface_properties it says that the cdata_mapping command ist
> specific to fac3d handles. But this fac3d is obsolete.

Fac3d is a (obsolete) Scilab primitive, but is is also a class of
graphic entities.

Read the beginning of the
http://help.scilab.org/docs/5.4.1/en_US/surface_properties.html
help page :
"Two classes appears under this type of entity : Plot3d and Fac3d
according to the plotting function or the way data is entered. Fac3d and
Plo3d entities are similar but Fac3d is more complete [...]."

Best regards.

--
Christophe Dang Ngoc Chan
Mechanical calculation engineer

______________________________________________________________________

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error), please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
______________________________________________________________________
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Antoine Monmayrant Antoine Monmayrant
Reply | Threaded
Open this post in threaded view
|

Re: Colorbar_same color code, different graphs

In reply to this post by Larissa
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" [hidden email]
*An:* "International users mailing list for Scilab." [hidden email]
*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
[hidden email]
http://lists.scilab.org/mailman/listinfo/users


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users



_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Larissa Larissa
Reply | Threaded
Open this post in threaded view
|

Re: Colorbar_same color code, different graphs

In reply to this post by Larissa
Hi Christophe,
 
it is perfect, thank you so much!!! It works perfectly! Really, it's amazing! :)
Thank you everybody for the great help as well!
 
Larissa
 
 
 
Gesendet: Dienstag, 23. Juli 2013 um 13:41 Uhr
Von: "Larissa Schultze" <[hidden email]>
An: "International users mailing list for Scilab." <[hidden email]>
Betreff: Re: [Scilab-users] Colorbar_same color code, different graphs
Hello Christophe,
 
well, I had tried that too actually, but error 144 appears even if it use genfac3d before...here is what I had tried already:
 
[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()
[xa,ya,za]=genfac3d(xx,yy,zp);
plot3d(xa,ya,za)
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)
 
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 
 
 
So I assume that there must be something missing/wrong somewhere else?
 
Thanks a lot,
Larissa
 
 
 
 
 
 
 
Gesendet: Dienstag, 23. Juli 2013 um 13:24 Uhr
Von: "Dang, Christophe" <[hidden email]>
An: "International users mailing list for Scilab." <[hidden email]>
Betreff: Re: [Scilab-users] Colorbar_same color code, different graphs
Hello,

> De la part de Larissa Schultze
> Envoyé : mardi 23 juillet 2013 12:59
>
> At surface_properties it says that the cdata_mapping command ist
> specific to fac3d handles. But this fac3d is obsolete.

Fac3d is a (obsolete) Scilab primitive, but is is also a class of
graphic entities.

Read the beginning of the
http://help.scilab.org/docs/5.4.1/en_US/surface_properties.html
help page :
"Two classes appears under this type of entity : Plot3d and Fac3d
according to the plotting function or the way data is entered. Fac3d and
Plo3d entities are similar but Fac3d is more complete [...]."

Best regards.

--
Christophe Dang Ngoc Chan
Mechanical calculation engineer

______________________________________________________________________

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error), please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
______________________________________________________________________
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users