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: Tue, 2 Sep 2008 00:06:16 -0700 (PDT)

Hi,

  If I do this, is there any way I can "overload" the plot() function such
that any call to plot(x) or plot(x,y) (one or two argument plots) will go to
my_plot() instead of plot()?

  Or would this require a hack in the code? (pointers as to which
files/modules should be changed would be much appreciated).

Ben



Matthias Brennwald (bwm) wrote:
> 
> On Mon, 2008-09-01 at 21:00 -0500, address@hidden wrote:
>> Message: 6
>> Date: Mon, 01 Sep 2008 18:39:12 -0400
>> From: Ben Abbott <address@hidden>
>> Subject: Re: Plotting, hold-on, colors
>> To: Ben Boxman <address@hidden>
>> Cc: address@hidden
>> Message-ID: <address@hidden>
>> Content-Type: text/plain; charset="us-ascii"
>> 
>> 
>> On Sep 1, 2008, at 5:25 PM, Ben Boxman wrote:
>> 
>> >
>> > Hi,
>> >
>> >  I've compiled the latest Octave (3.0.2) And the latest released  
>> > gnuplot
>> > (4.2.3).
>> >
>> >  I'm vexed by octave/gnuplot not changing colors when plotting  
>> > additional
>> > plots with hold-on. Yes, I know I can set colors manually (or pass
>> all
>> > arguments to one big plot call) -- but this is:
>> > 1) Cumbersome for normal plots.
>> > 2) Even more cumbersome when using hist() and other built-in
>> functions
>> > on-top of plot (with hist, you can get the output, and then call
>> yet  
>> > another
>> > function (bar -- that doesn't produce exactly the same results  
>> > ([x,y] =
>> > hist(z); bar(y,x);  -- is visually different than hist(z) --  
>> > probably some
>> > style default?)....).
>> >
>> >  This used to work properly in previous (<2.9.x) versions of
>> octave.  
>> > I use
>> > plots extensively, typically, I'll crunch some numbers in the  
>> > command line
>> > and blurt them out as a plot/histogram (much easier to do this in  
>> > octave
>> > than in gnuplot, any manipulation/processing/filtering is so much  
>> > easier
>> > inside of octave). Just about every second plot I make involves  
>> > multiple
>> >
>> >  Is there any quick solution for this?
>> >
>> >  Is this a gnuplot issue (e.g. like the zoom problem)? Will this
>> be  
>> > solved
>> > if I compile the unstable gnuplot 4.3?
>> >  Is there any way I can patch octave to fix this (e.g., changing the
>> > default 'blue' to something cyclic, and intercepting hold and  
>> > resetting said
>> > cyclic variable?)?
>> >
>> >
>> > Man thanks,
>> >
>> > Ben Boxman
>> 
>> The Octave developers are actively working to improve Octave's  
>> compatibility with Matlab.
>> 
>> Regarding  the order of the colors, you can change the order by  
>> modifying the "colororder" property associated with the axis.  See ...
>> 
>>  > get (gca, 'colororder')
>> 
>>   ans = 0.00000 0.00000 1.00000
>>         0.00000 0.50000 0.00000
>>         1.00000 0.00000 0.00000
>>         0.00000 0.75000 0.75000
>>         0.75000 0.00000 0.75000
>>         0.75000 0.75000 0.00000
>>         0.25000 0.25000 0.25000
>> 
>> so you could
>> 
>>         colors = get (gca, 'colororder')
>> 
>> them modify the colors and/or order and then
>> 
>>         set (gca, 'colororder', colors)
>> 
>> Is that sufficient for you needs?
>> 
>> Ben
> 
> As far as I can tell, the above solution works with plots where all
> lines (=data sets) are plotted using one single plot command.
> 
> However, the original question was related to the situation, where one
> plots the first data set using plot(...), then 'hold on', and the plot
> another data set above the first using a second plot(...). I believe to
> remember that Matlab does indeed use a different color for the second
> plot (but it's a long time since I used Matlab), so I'd suggest to
> change this behaviour in some future version of Octave. In the meantime,
> I'd suggest to write a custom function that handles the plot color and
> the 'hold on', e.g. somthing like this (not tested):
> 
> 
> function h = my_plot (x,y)
> 
> global my_col
> 
> if ~exist('my_col')
>       my_col = 0;
> end
> my_col = my_col+1;
> c = get (gca,'colororder); c = c(my_col,:);
> plot (x,y,c)
> 
> endfunction
> 
> _______________________________________________
> 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-tp19256790p19265172.html
Sent from the Octave - General mailing list archive at Nabble.com.



reply via email to

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