help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Plotting, hold-on, colors


From: Ben Boxman
Subject: Re: Plotting, hold-on, colors
Date: Wed, 3 Sep 2008 02:17:43 -0700 (PDT)


  Many thanks, this worked like a charm -- I might do some more poking
around in the plot scripts now that I know where they are, :-).

  I like Octave's non-matlab compatible features. Octave being more
forgiving to "C" style syntax (e.g. " vs. ') is a boon to my ingrained "C"
ways. And some octave packages are superior, in functionality, to the Matlab
packages.

Ben



David Bateman wrote:
> 
> Ben Boxman wrote:
>>   Setting colors manually works if you are dealing with a "simple" plot
>> (though this is somewhat annoying). This becomes a bit more "icky" if
>> you're
>> using other functions that end up calling plot (for instance: hist,
>> pwelch,
>> or a user function) -- there is a work-around (in that you can receive
>> the
>> raw plot data, and then call plot (or bar), rewrite said user function to
>> set a color externally (in lieu of the default color)), but this requires
>> multiple steps + setting colors for each and every one.
>>   (e.g. two hists() with hold on also aren't satisfactory)
>>
>>   My primary reason for using octave is convenience --  I can both
>> process &
>> visualize my data (which is often produced by a non-octave environment)
>> --
>> and I can do both in a simple/efficient manner -- which I can't do, as
>> easily, outside of octave.
>>
>> Ben
>>   
> 
> The behavior you describe is the Matlab compatible behavior, and many 
> users seem to want strict compatibility. That being said I can think of 
> an easy way to get the behavior you want. Try overloading the 
> __next_line_color__ function. For example add the function
> 
> function rgb = __next_line_color__ (reset)
> 
>   persistent color_rotation = [];
>   persistent num_colors = [];
>   persistent color_index = [];
> 
>   if (nargin < 2)
>     if (nargin == 1 && reset)
>       color_rotation = get (gca (), "colororder");
>       num_colors = rows (color_rotation);
>       ## Don't reset the color_index except if this is first call
>       if (isempty (color_index) || color_index > num_colors)
>         color_index = 1;
>       endif
>     else
>       ## Need this as original __next_line_color__ called first
>       if (! isempty (color_rotation))
>     color_rotation = get (gca (), "colororder");
>     num_colors = rows (color_rotation);
>       endif
>       if (isempty (color_index))
>         color_index = 1;
>       endif
> 
>       rgb = color_rotation(color_index,:);
>       if (++color_index > num_colors)
>         color_index = 1;
>       endif
>       color_index
>       rgb
>     endif
>   else
>     print_usage ();
>   endif
> 
> endfunction
> 
> in the front of your path. The color_index variable is never reset in 
> the above and so you'll cycle through the plot colors even if 
> __next_line_color__(true) is called to reset it.
> 
> D.
> 
> 
> 
> -- 
> David Bateman                                address@hidden
> Motorola Labs - Paris                        +33 1 69 35 48 04 (Ph) 
> Parc Les Algorithmes, Commune de St Aubin    +33 6 72 01 06 33 (Mob) 
> 91193 Gif-Sur-Yvette FRANCE                  +33 1 69 35 77 01 (Fax) 
> 
> The information contained in this communication has been classified as: 
> 
> [x] General Business Information 
> [ ] Motorola Internal Use Only 
> [ ] Motorola Confidential Proprietary
> 
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Plotting%2C-hold-on%2C-colors-tp19256790p19285663.html
Sent from the Octave - General mailing list archive at Nabble.com.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]