#29 How to read hex numbers from file?


I have an enormous dataset, where I want to plot the
first second agains the second.
Until here, everything ok, but the second column has
hexadecimal values, and in some of the values, it as the
letter "e", where Gnuplot considers exponent, instead of
the value.

For example, in this bit:

6239863 020065d8
6239864 020065dc
6239865 020065E0
6239866 020065E4
6239867 020065E8
6239869 020065Ec

, Gnuplot considers this like being:

6239863 020065d8
6239864 020065dc
6239865 2,01E+04
6239866 2,01E+08
6239867 2,01E+12
6239869 020065Ec

And prints completely stupid values, out of scale with
the rest of the values.

How can i explicitely say GnuPlot, that my second
column has 8 digits of hex values?
Or in another words, to consider E a value and not

My email is:


Thanks for your attention.


  • Hans-Bernhard Broeker

    • summary: Problem --> How to read hex numbers from file?
  • Hans-Bernhard Broeker

    Logged In: YES

    [A more meaningful subject line than "Problem" would have
    been nice...]

    What you want to do can't be done with gnuplot alone.
    gnuplot expects to read *floating point* numbers from files,
    and it'd be quite a significant change to make it accept
    integers, too.

    So you'll have to transform the file before passing it to
    gnuplot, or generate it in decimal format right away. For
    transformation, a simple awk script will probably do. It
    will even do the job on-the-fly (--> "help datafile special").

  • Ethan Merritt

    Ethan Merritt - 2004-07-06

    Logged In: YES

    I can't think of a way to persuade any version of gnuplot to
    read in hexadecimal data from a file. So this is a
    reasonable request for enhancement.

    But for the moment you are stuck with pre-processing your
    data through an external filter. Here's a junk perlscript:

    #!/usr/bin/perl -w
    while (<>) {
    ($a,$b) = split;
    print $a, " ", hex($b), "\n";

    And here's the corresponding command:

    plot "< cat datafile | junk.pl" using 1:2

  • Ethan Merritt

    Ethan Merritt - 2004-07-06
    • summary: How to read hex numbers from file? --> Problem
  • Hans-Bernhard Broeker

    • assigned_to: nobody --> broeker
    • summary: Problem --> How to read hex numbers from file?
    • status: open --> closed

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks