[Scilab-users] Random colours for plot markers

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

[Scilab-users] Random colours for plot markers

Hello,

I would like to generate random colours for the markers in a polar plot (for
example), but not sure what is needed.

adding:  f.color_map = rand(jetcolormap(64));  will give random colours for
each new plot, but what I would like to try is to randomise the colours of
the markers. In the following script, the polar plot generates point markers
but all red, is it possible to plot with random colours?

clear
clf()
// Enter the upper range
x = input("Enter the upper range : ");
angle=180/%pi;
p=primes(x);
rad=p;
theta=p*angle;

f = gcf();
f.figure_size=[1024,1024];
a=gca();
a.tight_limits=["on", "on"]
a.mark_mode="on"
a.mark_style=0
a.mark_size_unit="point"
a.mark_size=3
a.mark_foreground = 21 // <- sets the current marker colour from figure
properties

// plot the prime number in  polar coordinates
polarplot(theta,rad,style=0)

Thanks for any pointers
Lester



--
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
Rafael Guerra Rafael Guerra
Reply | Threaded
Open this post in threaded view
|

Re: Random colours for plot markers

Hi,

 

Maybe you could complement polarplot with scatter, as in rush example below:

 

clear

clf()

x = 300;

angle= %pi;

p=primes(x);

rad= p;

theta= -angle + 5*p*angle/x;

n = length(p);

f = gcf();

f.figure_size=[1024,1024];

mcolors = int(n*rand(p));

polarplot(theta,rad)

scatter(rad.*cos(theta),rad.*sin(theta),20,mcolors,"fill")

 

 

Regards,

Rafael

 


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

Re: Random colours for plot markers

Thanks Rafael,

That is a good solution. Would be nice if that was available directly in
Polarplot

Lester



--
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
Samuel GOUGEON Samuel GOUGEON
Reply | Threaded
Open this post in threaded view
|

Re: Random colours for plot markers

Le 27/06/2020 à 14:10, arctica1963 a écrit :
Thanks Rafael,

That is a good solution. Would be nice if that was available directly in Polarplot

There is no actual interest having all properties combinations available at calling time.
It's possible and easy to post-process the polarplot display to get what you require.
Example:

clf reset
t = linspace(0, 2*%pi, 30);
polarplot(t, -1 + sin(t));
c = gca().children.children;  // the curve
set(c, "mark_mode","on","mark_style",3,"mark_size",4);
c.mark_foreground = grand(1,size(c.data,1),"uin",1,size(gcf().color_map,1));


Samuel


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

Re: Random colours for plot markers

Thanks Samuel. Always good to learn different methods.



--
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
Samuel GOUGEON Samuel GOUGEON
Reply | Threaded
Open this post in threaded view
|

Re: Random colours for plot markers

Le 28/06/2020 à 08:28, arctica1963 a écrit :
> Thanks Samuel. Always good to learn different methods.


The fact that .mark_foreground and similarly .mark_background and
.mark_size values
can be a vector to customize the marks individually was introduced in
Scilab 6.0.0
but is still not documented in the polyline_properties page of 6.1.0.
The page is updated for the next 6.1.1 release.

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