defining colors

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

defining colors

Eduardo J. Adam-3
Dear octave users,
Is It possible to define different colors to the traditional colors used by the command plot,  by means of mixing red, blue and green colors and then, use this new color for a plot?
How can I do that?

Eduardo
--

Dr. Eduardo J. Adam
Prof. Adjunto Instrumentación y Control de Procesos
Facultad de Ingeniería Química
Santiago del Estero 2654, (S3000AOJ), Santa Fe, SF, Argentina
Tel. +54 (0342) 457-1167 Int. 2742



_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: defining colors

Juan Pablo Carbajal
On Sat, Nov 12, 2011 at 5:37 PM, Eduardo J. Adam <[hidden email]> wrote:

> Dear octave users,
> Is It possible to define different colors to the traditional colors used by
> the command plot,  by means of mixing red, blue and green colors and then,
> use this new color for a plot?
> How can I do that?
>
> Eduardo
> --
>
> Dr. Eduardo J. Adam
> Prof. Adjunto Instrumentación y Control de Procesos
> Facultad de Ingeniería Química
> Santiago del Estero 2654, (S3000AOJ), Santa Fe, SF, Argentina
> Tel. +54 (0342) 457-1167 Int. 2742
>
>
>
> _______________________________________________
> Help-octave mailing list
> [hidden email]
> https://mailman.cae.wisc.edu/listinfo/help-octave
>
>

Sure!

colors are defined with a 3x1 vector each element between 0 and one or
0 and 255 depending on the function. The first element is the amount
of red, second green, and third is blue.
To plot with and arbitrary color just do

plot(rand(10,1),'-o', 'color', [0.8 0.2 0.2])

I hope this helps

--
M. Sc. Juan Pablo Carbajal
-----
PhD Student
University of Zürich
http://ailab.ifi.uzh.ch/carbajal/
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: defining colors

bpabbott
Administrator

On Nov 12, 2011, at 2:44 PM, Juan Pablo Carbajal wrote:

> On Sat, Nov 12, 2011 at 5:37 PM, Eduardo J. Adam <[hidden email]> wrote:
>> Dear octave users,
>> Is It possible to define different colors to the traditional colors used by
>> the command plot,  by means of mixing red, blue and green colors and then,
>> use this new color for a plot?
>> How can I do that?
>>
>> Eduardo
>>
>
> Sure!
>
> colors are defined with a 3x1 vector each element between 0 and one or
> 0 and 255 depending on the function. The first element is the amount
> of red, second green, and third is blue.
> To plot with and arbitrary color just do
>
> plot(rand(10,1),'-o', 'color', [0.8 0.2 0.2])
>
> I hope this helps

You can also set the order of plot colors in the axes properties. For example,

        set (gcf, "colororder", jet (11))

This will define 11 colors using the jet() colormap.  You can test drive the color by ...

        plot (rand (11))

If you like this approach, but don't care for the colors, you can try the colormaps below.

        autumn
        bone
        cool
        copper
        flag
        gray
        hot
        jet
        ocean
        pink
        prism
        rainbow
        spring
        summer
        winter

Ben

_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: defining colors

pathematica
A short while ago, the members of the forum explained to me how to produce arbitrary colors. To show my thanks, I added a short section to the octave wiki, which might be found here

http://wiki.octave.org/wiki.pl?Producing_Graphical_Output

I hope that might be helpful.

PS It is interesting to learn of the existence of more predefined colors from this thread!

Best wishes
However good you think Octave is, it's much, much better.
Reply | Threaded
Open this post in threaded view
|

Re: defining colors

Eduardo J. Adam-3
Thanks for your help.

Eduardo

2011/11/12 pathematica <[hidden email]>
A short while ago, the members of the forum explained to me how to produce
arbitrary colors. To show my thanks, I added a short section to the octave
wiki, which might be found here

http://wiki.octave.org/wiki.pl?Producing_Graphical_Output

I hope that might be helpful.

PS It is interesting to learn of the existence of more predefined colors
from this thread!

Best wishes


--
View this message in context: http://octave.1599824.n4.nabble.com/defining-colors-tp4034817p4035403.html
Sent from the Octave - General mailing list archive at Nabble.com.
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave





_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: defining colors

pathematica
This post was updated on .
After some experimentation using the information provided by Ben, you might find the following of interest

octave-3.2.3:1> hold on
octave-3.2.3:2> t = linspace(0, 2*pi, 1001);
octave-3.2.3:3> for i = 1:64
> plot(t, sin(t-i/16), 'color', colormap(jet)(i,:))
> endfor
octave-3.2.3:4>

Edit
You might wonder why I chose i = 1:64. I chose this because:

>> size(colormap(jet))
ans =

   64    3


Presumably, it would be possible to do the same for colormaps other than jet.
However good you think Octave is, it's much, much better.