Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Help to load data file (.dat) to GNUplot in Windows Platform

1,274 views
Skip to first unread message

huaji...@gmail.com

unread,
Jan 19, 2008, 8:24:28 AM1/19/08
to
Hi,

I am new to GNUplot; where I installed Windows version.

However, I am stuck when I want to load data files (in excel) or
(in .dat) to generate graph.

I tried to find help version regarding this in Windows version but
could not found any relevant ones.

I tried to run command line but error of "cant' read file.dat" always
pops up.

Please help.Appreciate alot.


Thanks.

Rgrds,
Jason

Hans-Bernhard Bröker

unread,
Jan 19, 2008, 2:51:36 PM1/19/08
to
huaji...@gmail.com wrote:

> However, I am stuck when I want to load data files (in excel) or
> (in .dat) to generate graph.

The problem already starts with your stated intention. In gnuplot you
don't "load" data files. You just plot them.

> I tried to run command line but error of "cant' read file.dat" always
> pops up.

That means the problem is not even related to this being a data file.
It's much simpler. "file.dat" just is not in the current working
directory as you run the command, so referring to it just by name,
instead of by path and name, cannot work.

huaji...@gmail.com

unread,
Jan 19, 2008, 7:48:54 PM1/19/08
to

Hi,

I should have let you know aslo that I tried to point to the ".dat"
file which contains the points on my Desktop.
gnuplot> load "C:\Desktop\force.dat"

and the same error occur. For your information the .dat files contain
points only.

# This file is called force.dat
# Force-Deflection data for a beam and a bar
# Deflection Col-Force Beam-Force
0.000 0 0
0.001 104 51
0.002 202 101
0.003 298 148
0.0031 290 149
0.004 289 201
0.0041 291 209
0.005 310 250
0.010 311 260
0.020 280 240

Please advise. Thanks.


-Jaosn

On Jan 20, 6:51 am, Hans-Bernhard Bröker <HBBroe...@t-online.de>
wrote:

Glenn MacGougan

unread,
Jan 20, 2008, 3:16:35 AM1/20/08
to
On Jan 19, 5:48 pm, "huajie....@gmail.com" <huajie....@gmail.com>
wrote:

If you're doing simple plotting try plot2d, http://sourceforge.net/projects/plot2d,
it's easier to get started.

Save your data file without a the header lines, say to data.txt, or
save your excel sheet to a comma delimited file (.csv)


> 0.000 0 0
> 0.001 104 51
> 0.002 202 101
> 0.003 298 148
> 0.0031 290 149
> 0.004 289 201
> 0.0041 291 209
> 0.005 310 250
> 0.010 311 260
> 0.020 280 240

try the windows GUI

or

at the command line to plot col1 vs col2 and col1 vs col3 type:
plot2d.exe data.csv 1 2 1 3 -xlim 0.0 0.02 -xlabel "Deflection" -
ylabel "Force" -slabel 1 "Col-Force" -slabel 2 "Beam-Force"

or
edit the option file and type:
plot2d.exe -f options.txt

Glenn MacGougan

unread,
Jan 20, 2008, 3:17:35 AM1/20/08
to
> If you're doing simple plotting try plot2d,http://sourceforge.net/projects/plot2d,

> it's easier to get started.
>
> Save your data file without a the header lines, say to data.txt, or
> save your excel sheet to a comma delimited file (.csv)
>
> > 0.000 0 0
> > 0.001 104 51
> > 0.002 202 101
> > 0.003 298 148
> > 0.0031 290 149
> > 0.004 289 201
> > 0.0041 291 209
> > 0.005 310 250
> > 0.010 311 260
> > 0.020 280 240
>
> try the windows GUI
>
> or
>
> at the command line to plot col1 vs col2 and col1 vs col3 type:
> plot2d.exe data.csv 1 2 1 3 -xlim 0.0 0.02 -xlabel "Deflection" -
> ylabel "Force" -slabel 1 "Col-Force" -slabel 2 "Beam-Force"
>
> or
> edit the option file and type:
> plot2d.exe -f options.txt

Not that I don't love GNUPlot!

Karsten Hentsch

unread,
Jan 20, 2008, 5:24:23 AM1/20/08
to
Hi,

>I should have let you know aslo that I tried to point to the ".dat"
>file which contains the points on my Desktop.
>gnuplot> load "C:\Desktop\force.dat"
>

i think load is not what you want to do :)
"The load command executes each line of the specified input file as if it
had been typed in interactively"
you can create scripts which contain gnuplot commands and load these scripts
with the load command.

if you want to plot, you should use the plot command.
plot 'D:\Desktop\force.dat' using 1:2 will use column 1 for x-values and
column 2 for y-values.

Karsten

huaji...@gmail.com

unread,
Jan 20, 2008, 7:55:49 AM1/20/08
to
Hi,

Thanks for the replies and input.

I tried on the plot command:-

plot 'C:\Desktop\force.dat' using 1:2

and before that, I did "pwd" and the path is on the Desktop itself.

But the error still remains by saying "cant' read the data file
"force.dat"


Is that because I am using Windows Vista?
Actually, I would like to try plot these points in 3 dimensions
surface.

Please advise. Appreciate any help.

Thanks.

-Jason


On Jan 20, 9:24 pm, "Karsten Hentsch" <karsten.hent...@s2002.tu-

Karsten Hentsch

unread,
Jan 20, 2008, 12:13:41 PM1/20/08
to
>Hi,
>
>Thanks for the replies and input.
>
>I tried on the plot command:-
>
>plot 'C:\Desktop\force.dat' using 1:2
>
>and before that, I did "pwd" and the path is on the Desktop itself.

>
>But the error still remains by saying "cant' read the data file
>"force.dat"

maybe the comments in your datafile are the source of your problem
try following command
set datafile commentchars '#'

>
>
>Is that because I am using Windows Vista?
>Actually, I would like to try plot these points in 3 dimensions
>surface.

the you'll need splot instead of plot if you want to plot 3d
i think splot 'force.dat' 1:2:3 should do what you want.

Hans-Bernhard Bröker

unread,
Jan 20, 2008, 4:45:53 PM1/20/08
to huaji...@gmail.com
huaji...@gmail.com wrote:

> I should have let you know aslo that I tried to point to the ".dat"
> file which contains the points on my Desktop.
> gnuplot> load "C:\Desktop\force.dat"

Which part of my earlier reply that datafiles aren't "load"ed in gnuplot
was indecipherable? The command you want is

plot 'c:\Desktop\force.dat'

> and the same error occur.

I rather massively doubt that. The message would actually be

Cannot open load file 'c:Desktopforce.dat'

The reason for the file name coming out so strangely is that you used
"double quotes" instead of 'single quotes', and backslashes.

Hans-Bernhard Bröker

unread,
Jan 20, 2008, 4:49:58 PM1/20/08
to huaji...@gmail.com
huaji...@gmail.com wrote:

> plot 'C:\Desktop\force.dat' using 1:2
>
> and before that, I did "pwd" and the path is on the Desktop itself.
>
> But the error still remains by saying "cant' read the data file
> "force.dat"

It's most certainly not. gnuplot would report the name you actually
referred to, i.e. 'c:\Desktop\force.dat'.

> Is that because I am using Windows Vista?

Well, let's just say that c:\Desktop hasn't been the actual location of
a typical user's desktop in the file system since at least Windows 2000.
It'd rather be something like

'c:\documents and settings\my user name\Desktop'

0 new messages