My datafile is a .txt file named test, which has only two columns of
data. I try to load it using open button, but gnuplot cannot read it
and error always appears like the following:
gnuplot> 1.0000 13.5939
^
"C:\Documents ...\test.dat", line 1: invalid command
:( What's my problem? I appreciate any advice from you guys.
Yingying
Ist this the first line in your data file? Did you start with # X Y ?
Daniel Möller
How did you create your data file?
Make sure that you save the file as ANSI, not Unicode nor UTF-8.
--
email me: change "nospam" to "w.hennings"
Wilfried Hennings c./o.
Forschungszentrum (Research Center) Juelich GmbH, MUT
<http://www.fz-juelich.de/mut/mut_home>
All opinions mentioned are strictly my own, not my employer's.
> Hi all,
>
> My datafile is a .txt file named test, which has only two columns of
> data. I try to load it using open button, but gnuplot cannot read it
^^^^^^^^^^^^^^^^^^^^^^^^^
is this equivalent to the command?
load "<input-file>"
then of course this means that you try to open a datafile but using it like
a file with commands and settings for gnuplot.
instead you should try the commandline
plot "<datafile>"
plus more options you want to use.
Greetings Helmut
My datafile has no suffix. But I found that when I try to open it,
gnuplot always failed, but it added .dat to my datafile.
The Windows 98 version of Notepad always saves as ANSI.
The Windows XP version of Notepad saves as Unicode by default. To save
as ANSI, choose File - Save as - Coding: ANSI.
I'm not sure about the Windows 2000 version.
If it has NO suffix, give the filename without suffix.
If it HAS a suffix, include it.
The problem with your "plot" command is that gnuplot interprets the
backslashes in a special way. So your plot command should either be with
double backslashes
gnuplot>plot "C:\\Documents and ...\\test"
or with forward slashes
gnuplot>plot "C:/Documents and .../test"
> backslashes in a special way. So your plot command should either be with
> double backslashes
> gnuplot>plot "C:\\Documents and ...\\test"
> or with forward slashes
> gnuplot>plot "C:/Documents and .../test"
Or single quotes:
gnuplot>plot 'C:\Documents and ...\test'
--
Hans-Bernhard Broeker (bro...@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.
> My datafile has no suffix.
Odds are that's not actually true. Beware of Microsoft's
breathtakingly stupid "innovation" not show the actual suffix by
default, and notepad's equally silly habit of putting an extra ".txt"
suffix on every file you save without an extension (or one it doesn't
recognize).
> But I found that when I try to open it, gnuplot always failed, but
> it added .dat to my datafile.
No, it didn't add anything.
I tried to save my file as ANSI and change backslash to forwardslash
for the plot command, but neither of them could help.
You know what, if I put some commands into my .txt file, gnuplot works
well, but not for data.
Yingying
>Actually, I tried to use the plot command, but what I got is this:
>gnuplot>plot "C:\Documents and ...\test"
> ^
> can't read data file "C:\Documents and ...\test"
>or
If you save a file in Notepad it may add the extension .txt. If that
extension has been associated to Notepad, the Windows default is to
not display that extension in folder windows.
In WinXP: Try opening the folder containing the data file, then choose
the Tools menu and Folder Options. Select the View tab and scroll down
to the box "Hide extensions for know file types". If it is checked,
uncheck it. Then click OK. Then you can see the full name of your
file.
If you don't want to go through all that (or if you don't have Windows
XP), try test.txt as your data file name. It might just work.
Dan
To reply by email, change LookInSig to luecking
*** Posted via a free Usenet account from http://www.teranews.com ***
If gnuplot executes commands in the .txt file but doesn't plot data, you
seem to mix up the "open" and the "plot" command.
"Open" opens a file in which gnuplot expects commands. This file can
also contain data, but only after the appropriate command. See
documentation.
Nevertheless, if you want to have a separate file containing only data,
put the necessary commands in a file test.plt, including a command
plot 'test.txt' (plus other required plot options)
then create a separate file test.txt containing your data.
You can choose file names and extensions as you like, as long as you
correctly tell them to gnuplot. If you use the menu command "open",
gnuplot expects a file extension .dat .
As Hans-Bernhard Broeker wrote, be aware that Windows hides some
extensions. I recommend you open explorer, choose Extras - Folder
options - View and uncheck "Hide extensions for known file types". (The
names of the options may be different in your version of Windows, that's
just my translation from my German Windows.)
Actually, I find out that. To plot a datafile there are two ways.
1. Using open buttion to load it first. You may see a warning like: ...
line # : invalid command. It seems that gnuplot expect commands, not
data. But that's ok. Still you can plot it. Now the dirctory info to
your datafile is not needed. Just a command: plot "test.txt" or plot
'test.txt', both of them are ok.
2. Plot it directly. You have to tell gnuplot the directoy. This time
the command is: plot 'D:\...\test.txt'. Notice that plot
"D:\...\test.txt" doesn't work!
Finally, thank you all!
> 1. Using open buttion to load it first. You may see a warning like: ...
> line # : invalid command. It seems that gnuplot expect commands, not
> data. But that's ok.
Actually, no really. Loading that file is a rather spectacularly
circuituous way of changing the working directory of gnuplot to the
one the data file is in.
> 2. Plot it directly. You have to tell gnuplot the directoy. This time
> the command is: plot 'D:\...\test.txt'. Notice that plot
> "D:\...\test.txt" doesn't work!
It would, if you doubled the backslashes, or used forward slashes
in their place. I.e. all of the following will work:
plot "d:\\some\\place\\data.txt"
plot "d:/some/place/data.txt"
plot 'd:\some\place\data.txt'
plot 'd:/some/place/data.txt'
and
cd 'd:/some/place'
plot 'data.txt'
> Hi all,
>
> My datafile is a .txt file named test, which has only two columns of
> data. I try to load it using open button, but gnuplot cannot read it
> and error always appears like the following:
>
> gnuplot> 1.0000 13.5939
> ^
> "C:\Documents ...\test.dat", line 1: invalid command
That is Gnuplots delicate way of telling you that it does not know what
to do with your data; you have to supply appropriate instructions. You
can doe that on the command line of the Gnuplot window, or you can write
a little script (by convention with the ending .plt, but that is not
required), which in the most simple case needs only a single line:
plot "test.txt" with lines
This will create a 2D-plot with the data in the first column used for
the x-axis, and the second column for y. The plot will be scaled
automatically. The data points will be connected by straight line
segments. Use "points" instead of "lines" to have the data points marked
by symbols, or "linespoints" to have both.
Your Gnuplot installation directory (most likely "program files/gnuplot"
if you are on Wintel) should contain a Demo subdirectory with examples
what wonderful things Gnuplot can do for you, if you bother to learn its
scripting language. Note that the command files in this case have the
ending .dem, not .plt