help-octave
[Top][All Lists]

## Speeding up a plotting function

 From: babelproofreader Subject: Speeding up a plotting function Date: Wed, 2 Nov 2016 05:42:13 -0700 (PDT)

```I have written a simple plotting function, code below, but unfortunately it
takes some time to plot. Is there any way in which I could speed this up?

function hilo_conditional_plot( high , low , condition )
%HILO_CONDITIONAL_PLOT
%   Takes high, low and condition input vectors and plots a line chart of
highs
%   and lows coloured according to the condtion. For this basic version
there
%   are only 3 conditons; 1 for long, -1 for short and 0 for neutral; with
the
%   respective plot colours being blue, red and green.

date = ( 1 : length(high) )' ;
hold on ;

for ii = 1 : length( high )

if condition(ii) == 1
line( [ date(ii) date(ii) ] , [ low(ii) high(ii) ] , 'Color' , 'b' ,
'linewidth' , 2 ) ;
elseif condition(ii) == -1
line( [ date(ii) date(ii) ] , [ low(ii) high(ii) ] , 'Color' , 'r' ,
'linewidth' , 2 ) ;
elseif condition == 0
line( [ date(ii) date(ii) ] , [ low(ii) high(ii) ] , 'Color' , 'g' ,
'linewidth' , 2 ) ;
else
printf( 'Error in condition vector - a value != 1,-1 or 0' ) ;
end

end

grid minor on ;

hold off ;

--
View this message in context:
http://octave.1599824.n4.nabble.com/Speeding-up-a-plotting-function-tp4680459.html
Sent from the Octave - General mailing list archive at Nabble.com.

```