Gnuplot String Data - Graphics

This is a discussion on Gnuplot String Data - Graphics ; I have a datafile with string data in certain columns. I tried to display this as described in the documentation on page 23: plot 'file' using 2:3 (let's assume that in column 2 is the string data) Now gnuplot tells ...

+ Reply to Thread
Results 1 to 7 of 7

Gnuplot String Data

  1. Default Gnuplot String Data

    I have a datafile with string data in certain columns. I tried to
    display this as described in the documentation on page 23:

    plot 'file' using 2:3

    (let's assume that in column 2 is the string data)

    Now gnuplot tells me this error:

    warning: Axis range undefined due to improper data values. NaN? Inf?
    ^
    All points x value undefined

    any ideas why this doesn't work?
    cheers.


  2. Default Re: Gnuplot String Data

    In article <1183472530.450170.209090@q75g2000hsh.googlegroups.com>,
    <heinemann.stefan@gmail.com> wrote:
    >I have a datafile with string data in certain columns. I tried to
    >display this as described in the documentation on page 23:
    >
    >plot 'file' using 2:3
    >
    >(let's assume that in column 2 is the string data)
    >
    >Now gnuplot tells me this error:
    >
    >warning: Axis range undefined due to improper data values. NaN? Inf?
    > ^
    > All points x value undefined
    >
    >any ideas why this doesn't work?


    Yes. That command does not by itself tell gnuplot what you are
    trying to plot (lines, points, boxes, labels, ???). The program
    makes a guess based on the number of columns. In your case this
    is two ('using 2:3') but the best guess for two columns is
    "points using x coordinate from column 2 and y coordinate from
    column 3". Since column 2 is in reality a string, it doesn't
    work as a y coordinate and therefore you get no valid points.

    You probably want either:

    # columns 1,2,3 contain x coord, y coord, string
    plot 'file' using 1:2:3 with labels

    or

    # implicit x coord, y in column 2, string in column 3
    plot 'file' using 0:2:3 with labels
    --
    Ethan A Merritt

  3. Default Re: Gnuplot String Data

    Thanks for your reply.

    On Jul 3, 6:31 pm, merr...@u.washington.edu (Ethan Merritt) wrote:
    > Yes. That command does not by itself tell gnuplot what you are
    > trying to plot (lines, points, boxes, labels, ???). The program
    > makes a guess based on the number of columns. In your case this
    > is two ('using 2:3') but the best guess for two columns is
    > "points using x coordinate from column 2 and y coordinate from
    > column 3". Since column 2 is in reality a string, it doesn't
    > work as a y coordinate and therefore you get no valid points.


    I see. Can I make it work as a coordinate? So on one axis I have
    the strings that occure in the second column and on the other axis
    I have a numeric value (third column) and then points.

    Something in the direction like

    plot 'file' using 0:3:xticlabels(2) with points

    Now the problem here is that if for example the string 'A' occures
    twice in the datafile, there will be two A tics on the axis with one
    point each instead of one A tic with two points.


  4. Default Re: Gnuplot String Data

    In article <1183531356.144671.235530@k29g2000hsd.googlegroups.com>,
    <heinemann.stefan@gmail.com> wrote:
    >
    >I see. Can I make it work as a coordinate? So on one axis I have
    >the strings that occure in the second column and on the other axis
    >I have a numeric value (third column) and then points.


    Sorry, I don't understand how you want it to look.
    Could you draw a sketch somehow?



    --
    Ethan A Merritt

  5. Default Re: Gnuplot String Data

    On Jul 4, 7:48 pm, merr...@u.washington.edu (Ethan Merritt) wrote:
    > Sorry, I don't understand how you want it to look.
    > Could you draw a sketch somehow?


    I want it to look like in that picture:
    http://codedump.ch/stefu/tmp/strings-on-axis.png

    You might think now, "but it already does look like this". Yes it
    does,
    but not with the 'using' feature of gnuplot. I use gnuplot within a
    python
    program, so the program reads the data, maps the strings to the tics
    and passes it to gnuplot. After the new release I hoped I could let
    gnuplot manage this...


  6. Default Re: Gnuplot String Data

    In article <1183531356.144671.235530@k29g2000hsd.googlegroups.com>,
    >
    >Can I make it work as a coordinate? So on one axis I have
    >the strings that occure in the second column and on the other axis
    >I have a numeric value (third column) and then points.
    >
    >plot 'file' using 0:3:xticlabels(2) with points
    >
    >Now the problem here is that if for example the string 'A' occures
    >twice in the datafile, there will be two A tics on the axis with one
    >point each instead of one A tic with two points.


    How about this. Data file contains

    A <y-coord>
    D <y-coord>
    A <y-coord>
    C <y-coord>
    ....

    Predefine a mapping function:

    xcoord(char) = char eq "A" ? 1 \
    char eq "B" ? 2 \
    char eq "C" ? 3 \
    char eq "D" ? 4 \
    char eq "E" ? 5 \
    ... and so on ...

    Plot command is then

    plot <file> using (xcoord(strcol(1)):2 with points

    or, to be more similar to the sketch you gave

    plot <file> using (xcoord(strcol(2)):2:1 with labels
    --
    Ethan A Merritt

  7. Default Re: Gnuplot String Data

    Did the solution proposed work for someone, I am trying it and I get an error :
    gnuplot> xcoord(char)=char eq "A" ? 1
    ^
    ';' expected

+ Reply to Thread

Similar Threads

  1. Plotting a big amount of data in gnuplot
    By Application Development in forum Graphics
    Replies: 2
    Last Post: 12-02-2007, 07:07 AM
  2. Gnuplot Data format
    By Application Development in forum Graphics
    Replies: 3
    Last Post: 02-28-2007, 01:41 PM
  3. 4D data plotting with gnuplot
    By Application Development in forum Graphics
    Replies: 1
    Last Post: 02-27-2007, 03:01 PM
  4. gnuplot data file columns
    By Application Development in forum Graphics
    Replies: 1
    Last Post: 03-13-2006, 06:13 PM
  5. gnuplot data uniform distribution
    By Application Development in forum Graphics
    Replies: 3
    Last Post: 01-14-2006, 02:18 PM