[Scilab-users] plot(x) - define color

classic Classic list List threaded Threaded
5 messages Options
anna28 anna28
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] plot(x) - define color

Hi all,

I would need a help to improve my plot.
I must graph the trend of 20 variables with the function plot(x); I would
like to assign a different color/mark to each variable in order to make
graph understanding immedaite.

At the moment, I do like that and it works:

colour=['.r-','.g-','.k-','.b-','.m-','.r:','.g:','.k:','.b:','.m:','.r--','.g--','.k--','.b--','.m--','.r-.','.g-.','.k-.','.b-.','.m-.'];
for j=1:20
    plot(TestPH(j,:),colour(j));
end

but the plot is not very clear. I would like to add different color and to
reduce line styles, that are difficult to recognize in the plot.

Is there any way to add colors in the "coulour" array? (I cannot use white,
yellow and cyan because difficult to see with white background).

thanks!
Anna




--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
jbaudais jbaudais
Reply | Threaded
Open this post in threaded view
|

Re: plot(x) - define color

Hi,


> colour=['.r-','.g-','.k-','.b-','.m-','.r:','.g:','.k:','.b:','.m:','.r--','.g--','.k--','.b--','.m--','.r-.','.g-.','.k-.','.b-.','.m-.'];
> for j=1:20
>    plot(TestPH(j,:),colour(j));
> end
>
> but the plot is not very clear. I would like to add different color and to
> reduce line styles, that are difficult to recognize in the plot.


I don't if there is a dedicated function, but

colour=["red","blue","chocolate1",...]; // help color_list
for j=1:20
  plot(TestPH(j,:))
  gcf().children.children.children(1).foreground=color(colour(j));
end

gives a solution.

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

Re: plot(x) - define color

Hi,

Since 6.1 version, plot() yields the handles of created polyline
entities, allowing to improve the piece of code which has been proposed,
like this:

colour=["red","blue","chocolate1",...]; // help color_list
for j=1:20
   h = plot(TestPH(j,:))
   h.foreground=color(colour(j));
end

S.

Le 19/02/2021 à 10:37, Jean-Yves Baudais a écrit :

> Hi,
>
>
>> colour=['.r-','.g-','.k-','.b-','.m-','.r:','.g:','.k:','.b:','.m:','.r--','.g--','.k--','.b--','.m--','.r-.','.g-.','.k-.','.b-.','.m-.'];
>> for j=1:20
>>     plot(TestPH(j,:),colour(j));
>> end
>>
>> but the plot is not very clear. I would like to add different color and to
>> reduce line styles, that are difficult to recognize in the plot.
>
> I don't if there is a dedicated function, but
>
> colour=["red","blue","chocolate1",...]; // help color_list
> for j=1:20
>    plot(TestPH(j,:))
>    gcf().children.children.children(1).foreground=color(colour(j));
> end
>
> gives a solution.
>
> --Jean-Yves
> _______________________________________________
> users mailing list
> [hidden email]
> https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users

--
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
http://www.utc.fr/~mottelet

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

Re: plot(x) - define color


..because the question also mentions the line style:

in addition to:

    colour=["red","blue","chocolate1",...]; // help color_list

you can also create

    lineStyle = [ 1, 2, 3, 4, 2, 1 , ......]  // help polyline

and do:


for j=1:20
   h = plot(TestPH(j,:))
   h.foreground=color(colour(j));
   h.line_style = lineStyle(j)
end

BR
Philipp






Am Fr., 19. Feb. 2021 um 10:53 Uhr schrieb Stéphane Mottelet <[hidden email]>:
Hi,

Since 6.1 version, plot() yields the handles of created polyline
entities, allowing to improve the piece of code which has been proposed,
like this:

colour=["red","blue","chocolate1",...]; // help color_list
for j=1:20
   h = plot(TestPH(j,:))
   h.foreground=color(colour(j));
end

S.

Le 19/02/2021 à 10:37, Jean-Yves Baudais a écrit :
> Hi,
>
>
>> colour=['.r-','.g-','.k-','.b-','.m-','.r:','.g:','.k:','.b:','.m:','.r--','.g--','.k--','.b--','.m--','.r-.','.g-.','.k-.','.b-.','.m-.'];
>> for j=1:20
>>     plot(TestPH(j,:),colour(j));
>> end
>>
>> but the plot is not very clear. I would like to add different color and to
>> reduce line styles, that are difficult to recognize in the plot.
>
> I don't if there is a dedicated function, but
>
> colour=["red","blue","chocolate1",...]; // help color_list
> for j=1:20
>    plot(TestPH(j,:))
>    gcf().children.children.children(1).foreground=color(colour(j));
> end
>
> gives a solution.
>
> --Jean-Yves
> _______________________________________________
> users mailing list
> [hidden email]
> https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users

--
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
http://www.utc.fr/~mottelet

_______________________________________________
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: plot(x) - define color

In reply to this post by anna28
Le 19/02/2021 à 09:25, anna28 a écrit :
Hi all,

I would need a help to improve my plot.
I must graph the trend of 20 variables with the function plot(x); I would
like to assign a different color/mark to each variable in order to make
graph understanding immedaite.

At the moment, I do like that and it works:

colour=['.r-','.g-','.k-','.b-','.m-','.r:','.g:','.k:','.b:','.m:','.r--','.g--','.k--','.b--','.m--','.r-.','.g-.','.k-.','.b-.','.m-.'];
for j=1:20
    plot(TestPH(j,:),colour(j));
end

but the plot is not very clear. I would like to add different color and to
reduce line styles, that are difficult to recognize in the plot.

Is there any way to add colors in the "coulour" array? (I cannot use white,
yellow and cyan because difficult to see with white background).

thanks!
Anna

Example of plot() post-processing "vectorized" over curves:

x = linspace(0,10,100);
phases = 0:0.15:1.5;
[X,P] = ndgrid(x, phases);
h = plot(x, sin(X+P));

// No explicit loop over curves is required:
h.foreground = 10:2:30;  // indexed colors
// check for some curves
h(1).foreground
h(10).foreground

// Until color() is vectorized, we could also use named colors as in
colors = ["blue" "scilabcyan4" "pink" "orange" "red" "green" "magenta" "gray50" "slateblue" "peru" "sienna"]; // named colors => help color_list
h.foreground = addcolor(name2rgb(colors)/255);


Actually using named colors in linespec out of the 8 special ones could be useful, since Scilab's set of named colored is quite rich.

Samuel


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