Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a data file for gnuplot?

Tags:

gnuplot

I'm trying to make a graph with gnuplot. I specified my xrange, yrange, and labels, but when I typed in the following command:

gnuplot> plot "data.txt" using 1:2 with lines

gnuplot tells me:

warning: Skipping unreadable file "data.txt" No data in plot.

I don't understand how my data file is unreadable. This is what my data.txt looks like:

X       Y  [I didn't enter X and Y into my text file]  10000   0.030 5000    0.02 1000    0.012 

I know I must be doing something wrong -- this is my first time using gnuplot. I tried doing a Google search on how to make a proper data.txt file turns up zilch.


EDIT:

I feel like this may sound strange to ask at a programming Q&A site, but what should a typical text file w/data look like? I'm no computer programmer, just an undergrad trying to plot a graph for her biochemistry class.

like image 349
Miriam Avatar asked Sep 21 '11 01:09

Miriam


People also ask

How use gnuplot data file?

To plot functions simply type: plot [function] at the gnuplot> prompt. Discrete data contained in a file can be displayed by specifying the name of the data file (enclosed in quotes) on the plot or splot command line. Data files should have the data arranged in columns of numbers.

How do I save a gnuplot file?

There are two ways to save your work in gnuplot: you can save the gnuplot commands used to generate a plot, so that you can regenerate the plot at a later time. Or you can export the graph to a file in a standard graphics file format, so that you can print it or include it in web pages, documents, or presentations.

What files can gnuplot open?

Gnuplot can read binary data files. However, adequate information about details of the file format must be given on the command line or extracted from the file itself for a supported binary filetype. In particular, there are two structures for binary files, a matrix binary format and a general binary format.

How do I open a gnuplot file?

You can run a script two ways: Type load "scriptname" from within gnuplot. Or, from UNIX, run gnuplot by typing gnuplot scriptname . In this method, gnuplot will exit when your script is finished, so you may want to include PAUSE -1 "Hit any key to continue" as your last line.


2 Answers

Either as most people answered: the file doesn't exist / you're not specifying the path correctly.

Or, you're simply writing the syntax wrong (which you can't know unless you know what it should be like, right?, especially when in the "help" itself, it's wrong).

For gnuplot 4.6.0 on windows 7, terminal type set to windows

Make sure you specify the file's whole path to avoid looking for it where it's not (default seems to be "documents")

Make sure you use this syntax:

plot 'path\path\desireddatafile.txt' 

NOT

plot "< path\path\desireddatafile.txt>" 

NOR

plot "path\path\desireddatafile.txt" 

also make sure your file is in the right format, like for .txt file format ANSI, not Unicode and such.

like image 173
Paul Avatar answered Sep 21 '22 14:09

Paul


plot "data.txt" using 1:2 with lines  

works for me. Do you actually have blank lines in your data file? That will cause an empty plot. Can you see a plot without data? Like plot x*x. If not, then your terminal might not be set up correctly.

like image 35
David Nehme Avatar answered Sep 20 '22 14:09

David Nehme