#60 read xtics from file

closed-accepted
Ethan Merritt
None
5
2004-07-10
2004-03-23
Pavel Novikov
No

I suggest to add an opportunity to read xtics from
datafile. It can be useful, if you have data which do
not connected whith each other. For example, I have a
lot of similar datafiles which look like this:

#---------begin datafile-----------------
#enzyme activity error
G6PDH 4.745 0.77
NADPMDH 8.215 1.662
NADGDH 6.008 1.318
Inv.NADGDH 9.79 1.789
#---------end datafile-------------------

I want to plot it with boxes and to name every box. I
must do like this:
#---------begin script-----------------

set xtics rotate ("G6PDH" 0, "NADPMDH" 1,\ "NADGDH" 2, "Inv.NADGDH" 3)

plot "datafile" using 0:2:(0.25) w boxes fs pattern 1
#---------end script-------------------

I have to redefine xtics for every file manualy. But is
it possible to make simple indication that xdata is in
a string format. For example, by using a string format
specifier (%s in C):

set format x "%s"
plot "datafile" using 1:2:(0.25) w boxes

This commands will mean that column 1 used for xtics
labels and column 0 used instead of column 1 as x
values of data.

Another way:

' plot "datafile" using ("$1"):2:(0.25) w boxes '

Double-quoted parameter "$1" means that strings from
the first column will be used as xtics corresponding to
the values of zero column which will be used as x values.

Discussion

  • Ethan Merritt
    Ethan Merritt
    2004-03-25

    • status: open --> open-later
     
  • Ethan Merritt
    Ethan Merritt
    2004-03-25

    Logged In: YES
    user_id=235620

    Already done, and will go into the CVS tree as soon as
    version 4 is out. Check out patch #595850, are pull it from
    my website at
    <http://www.bmsc.washington.edu/people/merritt/gnuplot/>

    For your specific example you may also want the "histograms"
    patch #606169.

    With both patches in place, your file can be plotted using
    commands like
    plot 'datafile' using 0:3:xtic(1) with histograms

     
  • Ethan Merritt
    Ethan Merritt
    2004-03-25

    • assigned_to: nobody --> sfeam
     
  • Pavel Novikov
    Pavel Novikov
    2004-03-26

    Logged In: YES
    user_id=985531

    Thank you, I will try to use the "histograms" patch, but I
    have not understood does this patch allow to read ytics or
    ztics? And does your style supports horizontal histograms
    like this:

    |
    text1 |0000000
    |
    text2 |00000000000000000000
    |
    text3 |00000000000
    |
    text4 |00000000000000000
    |________________________
    0 1 2 3 4 5 6

    If it supports your patch will also correspond to my earlier
    feature request #921711 about horizontal boxes.

     
  • Ethan Merritt
    Ethan Merritt
    2004-03-26

    Logged In: YES
    user_id=235620

    The ability to read strings from a datafile, and use them
    for xtics, ytics, ztics, etc (including plot titles) is part
    of the "datastrings" patch #595850. The "histograms" patch
    assumes you already have this, and adds auto-layout of
    various box-plot, stacked-histogram, and clustered box plot
    styles.

    No, it does not provide horizontal histograms. The notion
    that the independent variable is represented by "x" is quite
    deeply embedded in the gnuplot code. Changing it to "y"
    would be non-trivial. However, you might find that the
    stacked histogram mode is equally good for presenting your data.

     
  • Ethan Merritt
    Ethan Merritt
    2004-07-10

    • status: open-later --> closed-accepted
     
  • Ethan Merritt
    Ethan Merritt
    2004-07-10

    Logged In: YES
    user_id=235620

    Now implemented in CVS version