How to plot this in matlab?
<p>I have following code    </p>

<pre><code>xr=randi([1 150],1,20)
    z=numel(xr);
    N=10;  %Window length
    gAll=zeros(1,z-N+1);
    for n=0:z-N;
        x=xr(1+n:N+n)
      d=max(x);
        m=numel(x);
        y=zeros(d,1);
        p=zeros(d,d);
        for k=1:m-1
        y(x(k))=y(x(k))+1; 
        p(x(k),x(k+1))=p(x(k),x(k+1))+1;
        end
        p=bsxfun(@rdivide,p,y);
        p(isnan(p)) = 0; 
        j=prod(p(p~=0));
        [~,~,idx] = unique(x);
        q=prod(hist(idx,1:max(idx))/numel(x));
        s=log(j);
        l=log(q);
        g=s+l
    gAll(n+1)=g;
    end
    plot(gAll)
</code></pre>

<p>I want a plot such a that for threshold line of gAll =-22, graph above threshold line should be in red color and  graph below threshold line should in blue, but graph should in continuous joint with these two different colors, how to do it.</p>