help-octave
[Top][All Lists]
Advanced

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

Re: Plotting basics


From: Ben Abbott
Subject: Re: Plotting basics
Date: Fri, 21 Feb 2014 03:39:00 -0500

On Feb 21, 2014, at 3:27 AM, Byron Hawkins <address@hidden> wrote:

> I’m trying to make some very simple line plots, and I keep getting errors and 
> strange output. My script just takes the matrix “plots” and the vector 
> “index” and does this:
>  
> if length(plots) > 0,
>   semilogy(index, plots);
> end;
>  
> 1.       There is a warning about “axis: omitting non-positive data in log 
> plot”. There are zeros in the matrix, but these are not drawn in the plot, 
> which makes it look incomprehensible. Is it a problem to plot zeros? I’m not 
> specifying any axis bounds, so maybe the auto-bounds generator is specifying 
> zero, and that conflicts with the semilogy() function? I need to show zeros, 
> but there needs to be logarithmic scaling too.

The log of zero is -infinity.  How would you like to illustrate that in your 
plot?

> 2.       All the documentation says that “semilogy” and “plot” work just the 
> same, but when I change “semilogy” to “plot”, I get errors about “subscript 
> indices must either be positive integers less than 2^31…” What does it mean? 
> Why can’t I have a linear plot?

The error indicates you are indexing an array with negative values and/or with 
values larger than 2^31.  For example ...

        x = rand (10,1);
        n = 2e50;
        x(n)
        error: subscript indices must be either positive integers or logicals
        n = -1;
        x(n)
        error: subscript indices must be either positive integers or logicals

> 3.       When I use the axis() function, all my inputs are ignored. It just 
> plots the same auto-bounds that it was plotting before. I call it like 
> “axis([1,30,-100,1000]);” before anything else happens in the script.

To make axis ([...]) apply to future commands, you need to add "hold on".  Try 
...

        axis([1,30,-100,1000]);
        hold on

... and then add your plot commands.

>  
> It would be really great if someone could point me in the right direction 
> here, I have a paper deadline coming up very soon and I am totally stuck with 
> this really basic plotting. Thanks for your help.
>  
> Byron




reply via email to

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