[Scilab-users] Fill plot line properties into a list

classic Classic list List threaded Threaded
6 messages Options
Jens Jens
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] Fill plot line properties into a list

Hello Scilab intimates,

The lines

Cspec=list('Color','r','thickness',5);
plot(1:5,Cspec(:))


are functional, but the lines

 Cspec=list('line_mode','off','mark_mode','on','mark_style',1,'mark_foreground',5,'mark_size',5);
plot([1:5],Cspec(:))


are not. What has to be changed?

I would like to use  line specifying lists as function input arguments.

Kind regards
Jens

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

Re: Fill plot line properties into a list

Hi Jen,

 

Several of the arguments you would like to use do not seem to be valid GlobalProperty members for plot().

Maybe you could use a function that takes as input a proper graphics handle and your list.

Herein a quick and dirty example:

 

//START OF CODE
function gce_list(h, list0)
   n = length(list0);
   if modulo(n,2)<>0 then
       printf("\nIncorrect number of GlobalProperty arguments!\n")
       return;
   end
   for i=1:n/2
      h(list0(2*i-1)) = list0(2*i);
   end
endfunction
 
x=1:10;
plot(x);
h=gce().children;
Cspec=list('line_mode','off','mark_mode','on','mark_style',1,'mark_foreground',5,'mark_size',10); 
gce_list(h,Cspec)
//END OF CODE

 

Regards,

Rafael


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

Re: Fill plot line properties into a list

Hi Rafael,
Thanks! Not as simple as I hoped, but it works.

Regards
Jens
------------------------------------------------------------------------------------------------------------------------------
Am 03.06.2018 01:33, schrieb Rafael Guerra:

Hi Jen,

 

Several of the arguments you would like to use do not seem to be valid GlobalProperty members for plot().

Maybe you could use a function that takes as input a proper graphics handle and your list.

Herein a quick and dirty example:

 

//START OF CODE
function gce_list(h, list0)
   n = length(list0);
   if modulo(n,2)<>0 then
       printf("\nIncorrect number of GlobalProperty arguments!\n")
       return;
   end
   for i=1:n/2
      h(list0(2*i-1)) = list0(2*i);
   end
endfunction
 
x=1:10;
plot(x);
h=gce().children;
Cspec=list('line_mode','off','mark_mode','on','mark_style',1,'mark_foreground',5,'mark_size',10); 
gce_list(h,Cspec)
//END OF CODE

 

Regards,

Rafael



_______________________________________________
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: Fill plot line properties into a list

In reply to this post by Jens
Hello Jens,

Le 02/06/2018 à 22:31, Jens Simon Strom a écrit :
Hello Scilab intimates,

The lines

Cspec=list('Color','r','thickness',5);
plot(1:5,Cspec(:))


are functional, but the lines

 Cspec=list('line_mode','off','mark_mode','on','mark_style',1,'mark_foreground',5,'mark_size',5);
plot([1:5],Cspec(:))


are not. What has to be changed?

I would like to use  line specifying lists as function input arguments.

As a workaround, you may use the following:

plot(1:5)
Cspec = list('line_mode','off','mark_mode','on','mark_style',1,'mark_foreground',5,'mark_size',5);
set(gce().children, Cspec(:))

Regards
Samuel

_______________________________________________
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: Fill plot line properties into a list

In reply to this post by Jens
Le 02/06/2018 à 22:31, Jens Simon Strom a écrit :
Hello Scilab intimates,

The lines

Cspec=list('Color','r','thickness',5);
plot(1:5,Cspec(:))


are functional, but the lines

 Cspec=list('line_mode','off','mark_mode','on','mark_style',1,'mark_foreground',5,'mark_size',5);
plot([1:5],Cspec(:))


are not. What has to be changed?

I would like to use  line specifying lists as function input arguments.

Presently, plot() accepts only "plot-like" properties names and values.
I agree that this is an issue, due to some wishes to make Scilab just a shadow of another language.

plot-like equivalences exist for some properties, but not for all, and some features are not documented.
The following code works and does what you aim to do:

Cspec = list('linestyle','none','marker','+','markforeground','r','marksize',5);
plot([1:5],Cspec(:))

Regards
Samuel


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

Re: Fill plot line properties into a list

Great,Samuel!
Now my script looks much better.

Thanks with kind regards

Jens
---------------------------------------------------------------------
Am 03.06.2018 11:26, schrieb Samuel Gougeon:
Le 02/06/2018 à 22:31, Jens Simon Strom a écrit :
Hello Scilab intimates,

The lines

Cspec=list('Color','r','thickness',5);
plot(1:5,Cspec(:))


are functional, but the lines

 Cspec=list('line_mode','off','mark_mode','on','mark_style',1,'mark_foreground',5,'mark_size',5);
plot([1:5],Cspec(:))

are not. What has to be changed?

I would like to use  line specifying lists as function input arguments.

Presently, plot() accepts only "plot-like" properties names and values.
I agree that this is an issue, due to some wishes to make Scilab just a shadow of another language.

plot-like equivalences exist for some properties, but not for all, and some features are not documented.
The following code works and does what you aim to do:

Cspec = list('linestyle','none','marker','+','markforeground','r','marksize',5);
plot([1:5],Cspec(:))


Regards
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