Using using with splot

Using using with splot

Post by Peter Cha » Fri, 07 Nov 1997 04:00:00



Hi there,

I'm using gnuplot 3.6beta338 at the moment and have encountered a problem
using a datafile w/ splot:

The data is saved as z values (one line per value w/ a blank line separating
the rows or datalines in gnuplot terminology). It is a rectangular grid of
values.

I want to adjust the scaling on the splot so that the x and y axes show the
correct values instead of row and column numbers.

One method to do this is to use 'using' to rescale x and y. But there seems
to be two hurdles to overcome:

 1) with 'using', there are three additional column numbers defined -
    0,-1,-2. The help says 'using 1' is equivalent to 'using 0:-1:1'
    but this is untrue (just try it).

    Column zero is defined as a point counter which is reset on double blank
    lines (or with a new index). It would be handy to have column 0 defined
    as a point counter that is reset on single blank lines then the help
    notes would be correct.

 2) the $ notation can not cope with negative integers.

So as a workaround I have to use the following to rescale a 30 by 30 grid of
data values to the ranges [0:1] & [0:360]

 splot 'data' index 1 using ($0/30.0 - int($0/30.0)):(column(-1)*12.0):1

Looking at the source, datafile.c line 119 indicates column number 0 should
reset at blank lines _not_ double blank lines. Perhaps you should add
         df_datum = -1;
to line 937 in df_readline(), to solve the first point. The second point
I've tried looking at but the scanner code defeats my casual inspection.

Could any gnuplot developer comment on this and suggest fixes or patches?

TIA
 Peter
--
Email to etzpc(at)unix.ccc.nottingham.NOSPAM.ac.uk

 
 
 

Using using with splot

Post by David Denho » Fri, 07 Nov 1997 04:00:00



> Hi there,
> I'm using gnuplot 3.6beta338 at the moment and have encountered a problem
> using a datafile w/ splot:
> The data is saved as z values (one line per value w/ a blank line separating
> the rows or datalines in gnuplot terminology). It is a rectangular grid of
> values.
> I want to adjust the scaling on the splot so that the x and y axes show the
> correct values instead of row and column numbers.
> One method to do this is to use 'using' to rescale x and y. But there seems
> to be two hurdles to overcome:
>  1) with 'using', there are three additional column numbers defined -
>     0,-1,-2. The help says 'using 1' is equivalent to 'using 0:-1:1'
>     but this is untrue (just try it).
>     Column zero is defined as a point counter which is reset on double blank
>     lines (or with a new index). It would be handy to have column 0 defined
>     as a point counter that is reset on single blank lines then the help
>     notes would be correct.

I think this has been suggested before. I agreed then, and I agree
now, but I think the stumbling block was that all the data-file
handling code has been abstracted into a separate module (datafile.c)
and the same $0 has to work for both plot and splot. But for plot,
we do not want it to reset at double-blank lines.

Quote:>  2) the $ notation can not cope with negative integers.

$n is a shorthand for column(n). This latter syntax can cope with
-ve numbers.

But column(-2) doesn't seem to be implemented at all !
( using -2:... probably works, but using (column(-2)) doesn't
 seem to)

datafile.c : f_column() is invoked when a gnuplot expression invokes
column()

void f_column()
{
        struct value a;
        int column;
        (void) pop(&a);
        column = (int) real(&a) - 1;
        if (column == -2)
                push( Ginteger(&a, line_count) );
        else if (column == -1) /* $0 = df_datum */
                push( Gcomplex(&a, (double) df_datum, 0.0) );
        else if (column < 0 || column >= df_no_cols || df_column[column].good!=DF_GOOD)
        {       undefined = TRUE;
                push (&a);  /* any objection to this ? */
        }
        else
                push( Gcomplex(&a, df_column[column].datum, 0.0) );

To add support for column(-2), you can add

        if (column == -3)
                push( Ginteger(&a, df_current_index) );

Quote:> So as a workaround I have to use the following to rescale a 30 by 30 grid of
> data values to the ranges [0:1] & [0:360]
>  splot 'data' index 1 using ($0/30.0 - int($0/30.0)):(column(-1)*12.0):1
> Looking at the source, datafile.c line 119 indicates column number 0 should
> reset at blank lines _not_ double blank lines. Perhaps you should add
>          df_datum = -1;
> to line 937 in df_readline(), to solve the first point. The second point

Unfortunately, that breaks  plot 'file' using 0:...
(doesn't it ?)

Quote:

> I've tried looking at but the scanner code defeats my casual inspection.

One problem is that -ve contants are actually tokenised as (unary -)
(positive constant). I was just being lazy in parse.c:factor() when
I put in the requirement that the next token be an integer.

        } else if (equals(c_token,"$")) {
                struct value a;
                if (!isanumber(++c_token))   <-------------------------
                        int_error("Column number expected", c_token);
                convert(&a, c_token++);
                if (a.type != INTGR || a.v.int_val < 0)
                        int_error("Positive integer expected", c_token);
                add_action(DOLLARS)->v_arg = a;

(If you are interested, show at (expression) shows the compiled expression.
 gnuplot> show at -3
        pushc 3
        uminus
)

dd
--

Tel +44 (0)1494 453376 (work)    +44 (0)1494 459742  (home)

 
 
 

Using using with splot

Post by Peter Cha » Sat, 08 Nov 1997 04:00:00


[...]

 >>  1) with 'using', there are three additional column numbers defined -
 >>     0,-1,-2. The help says 'using 1' is equivalent to 'using 0:-1:1'
 >>     but this is untrue (just try it).
 >
 >>     Column zero is defined as a point counter which is reset on double blank
 >>     lines (or with a new index). It would be handy to have column 0 defined
 >>     as a point counter that is reset on single blank lines then the help
 >>     notes would be correct.

Quote:>I think this has been suggested before. I agreed then, and I agree
>now, but I think the stumbling block was that all the data-file
>handling code has been abstracted into a separate module (datafile.c)
>and the same $0 has to work for both plot and splot. But for plot,
>we do not want it to reset at double-blank lines.

You mean single blank line here?

Quote:>>  2) the $ notation can not cope with negative integers.

>$n is a shorthand for column(n). This latter syntax can cope with
>-ve numbers.

[...] Patch deleted, (thanks).

Quote:>> So as a workaround I have to use the following to rescale a 30 by 30 grid of
>> data values to the ranges [0:1] & [0:360]

>>  splot 'data' index 1 using ($0/30.0 - int($0/30.0)):(column(-1)*12.0):1

>> Looking at the source, datafile.c line 119 indicates column number 0 should
>> reset at blank lines _not_ double blank lines. Perhaps you should add
>>          df_datum = -1;
>> to line 937 in df_readline(), to solve the first point. The second point

>Unfortunately, that breaks  plot 'file' using 0:...
>(doesn't it ?)

Reading the help, yes it would, oops. I suppose the way to do it properly is
have a test for whether we are reading for 2d or 3d data.

Quote:

>> I've tried looking at but the scanner code defeats my casual inspection.

>One problem is that -ve contants are actually tokenised as (unary -)
>(positive constant). I was just being lazy in parse.c:factor() when
>I put in the requirement that the next token be an integer.

>    } else if (equals(c_token,"$")) {
>            struct value a;
>            if (!isanumber(++c_token))   <-------------------------
>                    int_error("Column number expected", c_token);
>            convert(&a, c_token++);
>            if (a.type != INTGR || a.v.int_val < 0)
>                    int_error("Positive integer expected", c_token);
>            add_action(DOLLARS)->v_arg = a;

I did track it down to this line but how I would go about changing it left
me stumped.

Quote:>(If you are interested, show at (expression) shows the compiled expression.
> gnuplot> show at -3
>        pushc 3
>        uminus
>)

I suppose if c_token isn't a number but a unary operator, then you could
grab the next token which would be the postive constant and operated on that
before continuing with the conversion...

Thanks for the prompt response,

Peter

PS another superficial change: the paging in the help should taken into the
terminal window size (both at startup and with a resize).

 
 
 

1. how to make surfaces transparent when using splot?

hi:

I am using gnuplot - splot command to draw a 3-D graph, like:

splot "data.txt" using 1:2:3 w line 1, "data.txt" using 1:2:4 w lines 1,
"data.txt" using 1:2:5 w lines 1

I got three surfaces, but they overlap with each other. How can I make the
three surfaces transparent?

thanks,

bo

2. Video CD player for SGI

3. Problem about using splot with pm3d

4. best algorithm for spherical deformation of image?

5. using splot in GNUPLOT

6. Help:Modeler interface problem!

7. Getting y-axis Label on Left-hand Side Using splot

8. problem using splot with second axes

9. More questions about 3 D plot using splot

10. Using set hidden 3d with grid data in splot

11. question of splot using data file

12. bug using splot with dgrid3d on certain datafiles on a HPUX platform