Showing posts with label gnuplot. Show all posts
Showing posts with label gnuplot. Show all posts

17 September 2013

514. Extracting Frequency data from a gaussian 09 calculation for gnuplot

This is another python script.

Say you've done a computation along the lines of this:
#P rBP86/GEN 5D Pseudo(Read) Opt=() Freq=() SCF=(MaxCycle=999 ) Punch=(MO) Pop=()
and want the data in a neat data file, like this:
33.237 0.0023 0.0536 39.9976 0.0043 0.8305 69.7345 0.0129 0.3348 84.7005 0.0173 0.7027 [..] 3133.0068 6.2938 0.6114 3143.8021 6.3551 0.3775 3164.9242 6.4685 0.8829 3221.8787 6.6972 4.6005

Then you can use the following python (2.x) script, g09freq:

#!/usr/bin/python
# Compatible with python 2.7 
# Reads frequency output from a g09 (gaussian) calculation
# Usage ex.: g09freq g09.log ir.dat
import sys 

def ints2float(integerlist):
    for n in range(0,len(integerlist)):
        integerlist[n]=float(integerlist[n])
    return integerlist

def parse_in(infile):
    g09output=open(infile,'r')
    captured=[]
    for line in g09output:
        if ('Frequencies' in line) or ('Frc consts' in line) or ('IR Inten' in line):
            captured+=[line.strip('\n')]
    g09output.close()
    return captured
    
def format_captured(captured):
    vibmatrix=[]
    steps=len(captured)
    for n in range(0,steps,3):
        freqs=ints2float(filter(None,captured[n].split(' '))[2:5])
        forces=ints2float(filter(None,captured[n+1].split(' '))[3:6])
        intensities=ints2float(filter(None,captured[n+2].split(' '))[3:6])
        for m in range(0,3):
            vibmatrix+=[[freqs[m],forces[m],intensities[m]]]
    return vibmatrix

def write_matrix(vibmatrix,outfile):
    f=open(outfile,'w')
    for n in range(0,len(vibmatrix)):
        item=vibmatrix[n]
        f.write(str(item[0])+'\t'+str(item[1])+'\t'+str(item[2])+'\n')
    f.close()
    return 0

if __name__ == "__main__":
    infile=sys.argv[1]
    outfile=sys.argv[2]

    captured=parse_in(infile)

    if len(captured)%3==0:
        vibmatrix=format_captured(captured)
    else:
        print 'Number of elements not divisible by 3 (freq+force+intens=3)'
        exit()
    success=write_matrix(vibmatrix,outfile)
    if success==0:
        print 'Read %s, parsed it, and wrote %s'%(infile,outfile)


Run it as e.g.
g09freq g09.log test.out

The output is compatible with gnuplot:
gnuplot> set xrange [3500:0]
gnuplot> set yrange [10:-1]
gnuplot> plot './test.out' u 1:2 w impulse



It's trivial to add gaussian broadening (see e.g. this post)

31 July 2013

486. MS data, part IV: Making a stacked spectrum plot using gnuplot

In part 1, I showed you how to export MS data (MS= Mass Spectrometer/ry): http://verahill.blogspot.com.au/2013/07/474-exporting-data-from-wsearch32-and.html

In part 2, I showed you how to generate theoretical isotopic envelopes, and how to compare them with observed ones: http://verahill.blogspot.com.au/2013/07/480-ms-data-part-ii-plotting-and.html

In part 3, I showed you how to make contour plots of '3D' data -- in that particular case the extra dimension was cone voltage, but it could just as easily have been time: http://verahill.blogspot.com.au/2013/07/ms-data-part-iii-generating-matrix-by.html

In part 4, we'll use the same data as in part 3, but we'll make a stacked plot of it. This is a short post.

There is at least one other way of making a stacked plot in gnuplot, but it doesn't yield what I'd consider as being publication quality plots. It's also fairly restrictive in the type of data can be plotted. The method shown here is general and applicable to all types of data. You can e.g. use it for time-dependent NMR data...

Here's an example of a gnuplot script:
### Preamble start
set term png size 1000,500
set output 'stack.png'

set border 1
set xtics nomirror
set ytics nomirror
unset ytics

set xrange [100:3000]
set yrange [0:100]

set multiplot
set size 0.85,0.45
unset key

### Preamble over

### The stacked plot
set origin 0,0
set label "m/z" at 1500, -18
plot '0.dat' with lines lt -1

# we want the x axis to show ONLY for the first spectrum,
# so we turn it off for the remaining spectra.
# The same goes for our label (xlabel can be tricky 
# to position correctly)
unset label
set border 0
unset xtics
unset ytics

# Here we set the spacing (fx) the initial position of the second spectrum (f),
# the initial horizontal offset of the second spectrum relative to the first one (g),
# and the horizontal offset for all subsequent spectra (gy)

f=0.0025
fx=0.00
g=0.01
gy=0.02

# then we plot all the other spectra
set origin fx+0*f,gy+0*g
plot '10.dat' with lines lt -1

set origin fx+1*f,gy+1*g
plot '20.dat' with lines lt -1

set origin fx+2*f,gy+2*g
plot '30.dat' with lines lt -1

set origin fx+3*f,gy+3*g
plot '40.dat' with lines lt -1

set origin fx+4*f,gy+4*g
plot '50.dat' with lines lt -1

set origin fx+5*f,gy+5*g
plot '60.dat' with lines lt -1

set origin fx+6*f,gy+6*g
plot '70.dat' with lines lt -1

set origin fx+7*f,gy+7*g
plot '80.dat' with lines lt -1

set origin fx+8*f,gy+8*g
plot '90.dat' with lines lt -1

set origin fx+9*f,gy+9*g
plot '100.dat' with lines lt -1

set origin fx+10*f,gy+10*g
plot '110.dat' with lines lt -1

set origin fx+11*f,gy+11*g
plot '120.dat' with lines lt -1

set origin fx+12*f,gy+12*g
plot '130.dat' with lines lt -1

set origin fx+13*f,gy+13*g
plot '140.dat' with lines lt -1

set origin fx+14*f,gy+14*g
plot '150.dat' with lines lt -1

set origin fx+15*f,gy+15*g
plot '160.dat' with lines lt -1

set origin fx+16*f,gy+16*g
plot '170.dat' with lines lt -1

set origin fx+17*f,gy+17*g
plot '180.dat' with lines lt -1

set origin fx+18*f,gy+18*g
plot '190.dat' with lines lt -1

set origin fx+19*f,gy+19*g
plot '200.dat' with lines lt -1

set origin fx+20*f,gy+20*g
plot '210.dat' with lines lt -1

set origin fx+21*f,gy+21*g
plot '220.dat' with lines lt -1

set origin fx+22*f,gy+22*g
plot '230.dat' with lines lt -1

set origin fx+23*f,gy+23*g
plot '240.dat' with lines lt -1

set origin fx+24*f,gy+24*g
plot '250.dat' with lines lt -1

set origin fx+25*f,gy+25*g
plot '260.dat' with lines lt -1

set origin fx+26*f,gy+26*g
plot '270.dat' with lines lt -1

set origin fx+27*f,gy+27*g
plot '280.dat' with lines lt -1

set origin fx+28*f,gy+28*g
plot '290.dat' with lines lt -1

set origin fx+29*f,gy+29*g

plot '300.dat' with lines lt -1




and here's the plot:

If you want to make it really fancy, try this:
### Preamble start
set term png size 1000,800
set output 'stack.png'

set border 1
set xtics nomirror
set ytics nomirror
unset ytics

set xrange [100:3000]
set yrange [0:100]

set multiplot
set size 0.85,0.25
unset key

### Preamble over

### The stacked plot
set origin 0,0
set label "m/z" at 1500, -18
plot '0.dat' with lines lt -1

# we want the x axis to show ONLY for the first spectrum,
# so we turn it off for the remaining spectra.
# The same goes for our label (xlabel can be tricky 
# to position correctly)
unset label
set border 0
unset xtics
unset ytics

# Here we set the spacing (fx) the initial position of the second spectrum (f),
# the initial horizontal offset of the second spectrum relative to the first one (g),
# and the horizontal offset for all subsequent spectra (gy)

f=0.0025
fx=0.00
g=0.01
gy=0.02

# then we plot all the other spectra
set origin fx+0*f,gy+0*g
plot '10.dat' with lines lt -1

set origin fx+1*f,gy+1*g
plot '20.dat' with lines lt -1

set origin fx+2*f,gy+2*g
plot '30.dat' with lines lt -1

set origin fx+3*f,gy+3*g
plot '40.dat' with lines lt -1

set origin fx+4*f,gy+4*g
plot '50.dat' with lines lt -1

set origin fx+5*f,gy+5*g
plot '60.dat' with lines lt -1

set origin fx+6*f,gy+6*g
plot '70.dat' with lines lt -1

set origin fx+7*f,gy+7*g
plot '80.dat' with lines lt -1

set origin fx+8*f,gy+8*g
plot '90.dat' with lines lt -1

set origin fx+9*f,gy+9*g
plot '100.dat' with lines lt -1

set origin fx+10*f,gy+10*g
plot '110.dat' with lines lt -1

set origin fx+11*f,gy+11*g
plot '120.dat' with lines lt -1

set origin fx+12*f,gy+12*g
plot '130.dat' with lines lt -1

set origin fx+13*f,gy+13*g
plot '140.dat' with lines lt -1

set origin fx+14*f,gy+14*g
plot '150.dat' with lines lt -1

set origin fx+15*f,gy+15*g
plot '160.dat' with lines lt -1

set origin fx+16*f,gy+16*g
plot '170.dat' with lines lt -1

set origin fx+17*f,gy+17*g
plot '180.dat' with lines lt -1

set origin fx+18*f,gy+18*g
plot '190.dat' with lines lt -1

set origin fx+19*f,gy+19*g
plot '200.dat' with lines lt -1

set origin fx+20*f,gy+20*g
plot '210.dat' with lines lt -1

set origin fx+21*f,gy+21*g
plot '220.dat' with lines lt -1

set origin fx+22*f,gy+22*g
plot '230.dat' with lines lt -1

set origin fx+23*f,gy+23*g
plot '240.dat' with lines lt -1

set origin fx+24*f,gy+24*g
plot '250.dat' with lines lt -1

set origin fx+25*f,gy+25*g
plot '260.dat' with lines lt -1

set origin fx+26*f,gy+26*g
plot '270.dat' with lines lt -1

set origin fx+27*f,gy+27*g
plot '280.dat' with lines lt -1

set origin fx+28*f,gy+28*g
plot '290.dat' with lines lt -1

set origin fx+29*f,gy+29*g

plot '300.dat' with lines lt -1

### second plot
set size 0.75,0.4
set origin 0.1,0.6
set xrange [800:1800]
set border 3
set xtics nomirror
set ytics nomirror
set xlabel 'm/z'
set ylabel 'Relative abundance (%)'
set title '20 V'

plot '20.dat' with lines lt -1

unset multiplot

which looks like this:

03 March 2013

353. Cygwin with octave and gnuplot on windows XP.

Here's my fourth Windows XP post.

Again, the goal is primarily to get Gnuplot and Octave working on Windows, together with sed, gawk and other tools for data processing. In this post that's done using cygwin on windows XP.

This is (in my opinion) a better alternative to installing the native gnuplot and octave packages (posts 350, 351, 352), especially as Octave in post 350 takes well over a minute to start, but only a few seconds through cygwin.

1. Download http://cygwin.com/setup.exe and run it. Set it to install from the internet, with c:\cygwin as the root directory. Pick a mirror which is reasonably close (e.g. mirror.aarnet.edu.au in Australia).

2. You're now asked to select packages.
Select octave (search for octave, click on 'skip' to change it to the version number), octave-forgegnuplot, xinit and xorg-server

3. Cygwin will calculate dependencies. cat, gawk, sed etc. are part of the base package and don't need to be explicitly selected.

I got a single error during installation, but it doesn't seem to have caused any obvious issues:
Package: libpango1.0_0 pango1.0.sh exit code 1
4. Launch Programs/Cygwin-X/XWin server.
Unblock if necessary.

Do
echo $DISPLAY
:0
to make sure that all is well. Run gnuplot and do e.g. 'plot x w lines' to make sure that all is working. Best thing? Octave only takes a few seconds to start... You may have to load packages in octave manually (e.g. 'pkg load all')



Links to this post:
http://blog.csdn.net/lllcfr1/article/details/8657143

351. Installing gnuplot on Windows XP

Here's my second Win XP post.

Here's how to set up gnuplot on windows XP. You can also set it up using cygwin: http://verahill.blogspot.com.au/2013/03/353-cygwin-with-octave-and-gnuplot-on.html

1. Download
Go to http://www.tatsuromatsuoka.com/gnuplot/Eng/winbin/ and download http://www.tatsuromatsuoka.com/gnuplot/Eng/winbin/gp470-20120916-win32-mingw-setup.zip

You'll need e.g. 7zip to extract the file.

2. Install and set up
Extract the  gp470-20120916-mingw.exe file to some temporary place, and then launch the installation by double-clicking on it. Most installation steps are straight-forward. Set windows as the default terminal, and make sure to check the box to add the application directory to PATH.

3. Usage
Launch gnuplot from the windows start menu as any other program if you want it to run interactively.

Alternatively, create a script and launch it using "gnuplot scriptname" from cmd as you would under linux.

06 February 2013

332. Gnuplot: bug(?) in current debian testing package

Update 2:
"Note that gnuplot uses both "real" and "integer" arithmetic, like FORTRAN and C. Integers are entered as "1", "-10", etc; reals as "1.0", "-10.0", "1e1", 3.5e-1, etc. The most important difference between the two forms is in division: division of integers truncates: 5/2 = 2; division of reals does not: 5.0/2.0 = 2.5. In mixed expressions, integers are "promoted" to reals before evaluation: 5/2e0 = 2.5. The result of division of a negative integer by a positive one may vary among compilers. Try a test like "print -5/2" to determine if your system chooses -2 or -3 as the answer."

http://www.physics.drexel.edu/courses/Comp_Phys/General/Graphics/gnuplot.html

I guess it's a feature. I guess I just need to remind myself of it every now and again...

Update: version 3.7.3 behaves the same way.


I use gnuplot for fitting data for scientific publications and every time I discover a bug it makes me seriously worried that I've somehow published something which will turn out to be incorrect.

It's not without reason -- Gnuplot version 4.4.0 in Debian Testing garbled small and large numbers: http://verahill.blogspot.com.au/2012/02/debian-testing-wheezy-64-bug-in-debian.html

I'm not sure whether this is a bug, but gnuplot 4.6.0 (current version in debian testing) screws up fractional powers.

gnuplot> print 9**(1/2)
1
gnuplot> print 9**(0.5)
3.0
gnuplot> print sqrt(9)
3.0

Somehow this works:
gnuplot> print 10**(2)
100
gnuplot> print 10**(2.0)
100.0
gnuplot> print 10**(6/3)
100
but not this
gnuplot> print 10**(1)
10
gnuplot> print 10**(1/2)
1
gnuplot> print 10**(1/3)
1
gnuplot> print 10**(0.3333333)
2.15443452467292
gnuplot> print 10**(1/3.0)
2.15443469003188

So the error seems to be due to the usual issue of distinguishing between integer values and real values e.g. the following example in Python 2.7:
>>> print 1/3
0
>>> print 1/3.0
0.333333333333

I still don't think this is intended behaviour in gnuplot, and it's certainly dangerous

Upstreams version 4.6.1
wget http://downloads.sourceforge.net/project/gnuplot/gnuplot/4.6.1/gnuplot-4.6.1.tar.gz
tar xvf gnuplot-4.6.1.tar.gz
cd gnuplot-4.6.1/
./configure --program-suffix=-4.6.1 --prefix=$HOME/.gnuplot-dev
make
make install
cd $HOME/.gnuplot-dev/bin
./gnuplot-4.6.1

gnuplot> print 9**(1/3)
1
gnuplot> print 10**(1/3)
1
gnuplot> print 10**(6/3)
100
gnuplot> print 10**(3/6)
1

25 January 2013

327. Installing Octave, Gnuplot, maxima etc on OSX 10.8.2 via macports

Update 7 Feb 2013: Got my hand on a Mac again and sorted out the octave forge packages.

NOTE: while on the surface this has little to do with linux, it IS in our interest to get people on other platforms to use the same tools we do. Or at least compatible ones. So knowing about macports will help even the most die-hard linux user. In fact, it will help especially those.


I'm no friend of Apple, Mac or OS X for many reasons (restrictive environment, weird mouse, their typical target audience), but pragmatism will make you happier than zealotry. What doesn't work for me obviously works for other people.

Students (and professors) at Australian universities do use apple laptops in significant number though (yet our ERP system only works properly with Internet Explorer -- try requesting leave using chrome on linux and you may be in for a surprise) so I've recently been faced with the issue of installing my standard linux tools on students' apple laptops. In fact it's gotten so bad that several Australian universities 'give' ipads to all their students for 'free' (nothing is free when you're paying for it through your tuition). As someone working at a uni I resent this since, by using the one platform where you can't install what you want on it, this puts pressure on me to restrict my teaching to what can be had via the almighty app store. (there's a lot of BS about blended learning, and you'd be lucky to find a white board anywhere. Blackboards are completely gone which is idiocy of the first degree)

Anyway. There's plenty of people here using Macbook-thingies and it's in my own interest to get them on the narrow path to justice, liberty and the FOSS way.

Macports is a really cool package manager/repository for linux software for Mac OSX and works by compiling the software from the sources -- pretty much how I imagine that the Gentoo experience may be like. Anyway, it works fine although it takes a fair amount of time to install things.


So here's how to do it (no screenshots because I'm typing this from memory):
  1. Open the App Store and install XCode (free)
  2. Open Xcode, go to Preferences/Download, and install Command Line Tools
  3. Download macports via this link for OS X 10.8: https://distfiles.macports.org/MacPorts/MacPorts-2.1.2-10.8-MountainLion.pkg
    Other versions of OS X are also supported, see here: http://www.macports.org/install.php
  4. Install the downloaded macports by opening the .pkg file
  5. Open a Terminal window  (Applications/Utilities/Terminal) and run
  6. sudo port -v selfupdate
  7. Run
  8. sudo port install gnuplot maxima vim nano xterm
    which will take a while -- it needs to set up the build environment from scratch in addition to regular dependencies. Set aside an hour or so just in case. If there's an error, try running the command once more.

  9. Run
  10. sudo port install octave-devel qtoctave-mac
    which will take a long while. If the compile seems to have stopped, checked the titlebar of the terminal window -- the command it's executing will continously change during the compile)

  11. Run octave by running the command
    octave
    in the terminal.
  12. To install octave packages you can install them in the Octave environment :
    pkg install -forge miscellaneous struct general optim
  13. addpath
  14. In case you're having problems actually using the octave-forge packages, you might need to create/edit your ~/.octaverc along the lines of
    addpath('/Users/verahill/octave/optim-1.2.2')
    Replace verahill with the proper user name, and edit the version number as needed.

  15. X11/Xquartz - setting DISPLAY
  16. At this point
    echo $DISPLAY
    gave nothing, and trying to launch an X11 program (e.g. xterm) complained that DISPLAY was not set. Setting DISPLAY manually (export DISPLAY=:0.0) didn't help either.

    'Bad' solution: the first solution was to install xorg-server (sudo port install xorg-server), and then manually
    X &
    export DISPLAY=:0.0
    
    or
    Xquartz &
    export DISPLAY=:0.0
    
    Both X and Xquartz come from macports.

    Good solution
    I then tried to change tack and went to http://xquartz.macosforge.org/landing/ and downloaded XQuartz-2.7.4.dmg (I was originally under the impression that it came as default with "mountain lion" but no.).
    Open the file, then run the .pkg file in that archive. Log out of OSX, then log in again. Now try launching e.g. xterm form a terminal and it should work.


The entire process will take well over an hour, but at the end of it you'll have Octave, Gnuplot AND a complete build environment!

And there are plenty more things you can install with macports (e.g. qtoctave (qtoctave-mac), gedit (gedit gedit-plugins), kile, maxima, qtiplot).

Not sure why I am so excited over it since all these things are available in most linux repos, but there you go -- compiling stuff is ALWAYS exciting.

06 June 2012

177. Jerry-rigging g09 UV/VIS spectra in gnuplot and/or octave

EDIT: I had a nicer post with lots of figures before. Because I realised that the data is good enough to be included in a future paper we're working on, I had to take everything down again. All the data in the plots now is made up (hence 'fakeuv.dat'), and I haven't made the plots look nice.

I don't like proprietary formats for anything. They never, ever benefit anyone other than the software vendor.

Almost as bad as using binary proprietary formats is not providing export facilities to ascii formats.

I may have missed it, but I was using gaussview to look at td-dft calculated uv/vis spectra -- and couldn't find a way of exporting the data. Sure, I could export the graph as a png, svg etc. file. But not double column tab-separated ascii file.

There's a bit of fudging in what I'm doing  -- I'll be the first one to admit that.

So here's single line to export the wavelengths and intensities:
cat g03.g03out|grep Excited|grep -v singles|sed 's/=/\t/g'|gawk '{print $7,$10}'>uvvis.dat

You can plot them in gnuplot using
plot 'uvvis.dat' u 1:2 w impulse

The problem is that these are just spikes -- not the smooth uv/vis like spectra we're used to. On the other hand, if I understand things correctly, this is the REAL data, while the smoothed uv/vis spectrum above is more for presentation purposes. I might obviously be wrong, and I am by no stretch a computational or theoretical chemist - I just like their tools.

We've got an immensely powerful tool at our hands: Octave!
data=load('fakeuv.dat');
gauss= @(x,c,r,s) r.*1./(s.*sqrt(2*pi)).*exp(-0.5*((x-c)./s).^2)
x=linspace(250,850,600);
plot(x,cumsum(gauss(x,data(:,1),data(:,2),20)))

where 20 is an abitrary value. Anyway, this is how it looks:
We can try s=30 instead:

We export it
outdata=cumsum(gauss(x,data(:,1),data(:,2),30));
exportdata=[x' outdata'];
save 'uvvis2.sim' exportdata
and plot it in gnuplot
plot 'uvvis2.sim' u 1:48 w lines
It might not look like the UV/VIS spectrum you're used to, but as I said in the beginning, the data's all made up -- using 'real' calculated data I got a beautiful spectrum.

17 February 2012

70. Bug in Debian version of Gnuplot 4.4.0

The symptom:

Gnuplot 4.4.0-1.1 (the current Debian version) can't handle numbers smaller than 10**(-9) properly
e.g.
me@beryllium:~/Dropbox$ gnuplot
G N U P L O T
Version 4.4 patchlevel 0
last modified March 2010
System: Linux 3.2.0-1-amd64
Copyright (C) 1986-1993, 1998, 2004, 2007-2010
Thomas Williams, Colin Kelley and many others
gnuplot home:     http://www.gnuplot.info
faq, bugs, etc:   type "help seeking-assistance"
immediate help:   type "help"
plot window:      hit 'h'
Terminal type set to 'wxt'
gnuplot> print 10**(-9)
1e-09
gnuplot> print 10**(-10)
7.09186959928599e-10
gnuplot> print 10**(-11)
8.22536045240377e-10

It's not related to set zero.

gnuplot> set zero 1e-20
gnuplot> print 10**(-11)
8.22536045240377e-10
gnuplot> print 10**(-10)
7.09186959928599e-10
gnuplot> print 10**(-9)
1e-09
gnuplot> 

Currently, I'm using version 4.4.0-1.1 -- which is used in all versions of Debian.


me@beryllium:~$ apt-cache showpkg gnuplot
Package: gnuplot
Versions:
4.4.0-1.1 (/var/lib/apt/lists/ftp.au.debian.org_debian_dists_testing_main_binary-amd64_Packages) (/var/lib/apt/lists/ftp.au.debian.org_debian_dists_stable_main_binary-amd64_Packages) (/var/lib/apt/lists/ftp.au.debian.org_debian_dists_unstable_main_binary-amd64_Packages) (/var/lib/dpkg/status)
..
Dependencies:
4.4.0-1.1 - gnuplot-nox (2 4.4.0-1.1) gnuplot-x11 (2 4.4.0-1.1) gnuplot-doc (2 4.4.0-1.1)
Provides:
4.4.0-1.1 -
Reverse Provides: 

The bug affects the output from the print statement as well as the internal handling of numbers:




gnuplot> plot 10**(-11)
Warning: empty y range [8.22536e-10:8.22536e-10], adjusting to [8.14311e-10:8.30761e-10]



gnuplot> plot 10**(-12)
Warning: empty y range [-1.3748e-09:-1.3748e-09], adjusting to [-1.36105e-09:-1.38855e-09]
gnuplot> plot 10**(-12)/10**(-10)
Warning: empty y range [-1.93855:-1.93855], adjusting to [-1.91917:-1.95794]





gnuplot> set xrange [10**(-9):10**(-12)]
gnuplot> plot x 



The bug is similar to this: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=360087

Integer overflows are not reported. A hint could be printed that real
(float) numbers should (could) be used to avaid this problem.
gnuplot> print 1000000*100000
1215752192
gnuplot> print 1000000**2
-727379968
gnuplot> print 100000**2
1410065408
gnuplot> a=2000000**2
gnuplot> print a
1385447424
gnuplot> print 10000**2 # OK
100000000
which ended up with "Added tag(s) wontfix. "
Ergo, if you're using debian and you are using gnuplot for serious purposes (research, work), compile your own version of gnuplot as per below.


ANNOYING: there are packages such as maxima which depend on gnuplot. Remove the debian version of gnuplot using apt-get and you lose maxima too. Octave, which one would think would be a heavier user of gnuplot, does not depend on gnuplot but merely recommends it.


Package: maxima                        
State: not installed
Version: 5.26.0-3
Priority: optional
Section: math
Maintainer: Camm Maguire <camm@debian.org>
Uncompressed Size: 47.8 M
Depends: libc6 (>= 2.3), libgmp10, libreadline6 (>= 6.0), libx11-6, gnuplot-x11
Maybe time to build your own maxima.deb? In the end you will end up with a very inelegant system with mixed packages.


Upstreams:
I've compiled and checked the current upstreams version:

me@beryllium:~$ sudo apt-get autoremove gnuplot gnuplot-nox
cd ~/temp
wget http://downloads.sourceforge.net/project/gnuplot/gnuplot/4.4.4/gnuplot-4.4.4.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fgnuplot%2Ffiles%2F&ts=1329439455&use_mirror=aarnet
 mv gnuplot-4.4.4.tar.gz\?r\=http\:%2F%2Fsourceforge.net%2Fprojects%2Fgnuplot%2Ffiles%2F gnuplot-4.4.4.tar.gz
tar -xvf gnuplot-4.4.4.tar.gz
./configure
make 
sudo checkinstall


me@beryllium:~/temp/gnuplot-4.4.4$ sudo dpkg -i gnuplot_4.4.4-1_amd64.deb
(Reading database ... 446323 files and directories currently installed.)
Preparing to replace gnuplot 4.4.4-1 (using gnuplot_4.4.4-1_amd64.deb) ...
Unpacking replacement gnuplot ...
Setting up gnuplot (4.4.4-1) ...
Processing triggers for man-db ...
me@beryllium:~/temp/gnuplot-4.4.4$ gnuplot
G N U P L O T
Version 4.4 patchlevel 4
last modified November 2011
System: Linux 3.2.0-1-amd64
Copyright (C) 1986-1993, 1998, 2004, 2007-2011
Thomas Williams, Colin Kelley and many others
gnuplot home:     http://www.gnuplot.info
faq, bugs, etc:   type "help seeking-assistance"
immediate help:   type "help"
plot window:      hit 'h'
Terminal type set to 'x11'
gnuplot> print 10**(-9)
1e-09
gnuplot> print 10**(-10)
1e-10
gnuplot> print 10**(-11)
1e-11
gnuplot> print 3.14*10**(-10)
3.14e-10
gnuplot> print 3.14*10**(-20)
3.14e-20
gnuplot> print 3.14*10**(-21)
3.14e-21
gnuplot> print 3*10**(-12)/(4*10**(-14))
75.0
gnuplot> 

Ergo, upstreams v 4.4.4 works.

Update: Here's my bug report:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=660299