How do I make an output of my graph without using 'exit'??
It makes me crazy because when the sizes go wrong, I have to do it from the start again.
I did all the stuff like set term pdf and all that. Please tell me what can I do.
to flush the buffer to the file you need to put a set output after issuing the plot or splot command(s).
example:
set term pdf
set output 'test.pdf'
plot sin(x)
set output
Here is a FAQ answer to your problem
Related
I've already created a txt file containing only numbers just to see how Gnuplot works, but it keeps on telling me it "cannot find or open 'myfile.txt' no data in plot". I followed step by step many tutorials but it didn't help at all.
Any tips?
(P.S: my gnuplot does work, since I also testify it by plotting the sin(x) function. And it succeeded).
Most importantly, you must give a windows path name, with backslashes, in 'single quotes', not "DOUBLE QUOTES". Text in double quotes gets backslash processing, and you don't want the file name "C:\note" to contain a line break, see also help quote marks.
Otherwise, run the following in gnuplot
set table 'sinx.dat'
plot sin(x)
unset table
plot 'sinx.dat'
pwd
You should now have a data plot with a hundred points in the form of a sine on screen.
Now look for the file sinx.dat on your hard drive. It's in the directory that the pwd command returned. If the datafile you originaly wanted to plot is somewhere else, you know what the problem is.
I haven't found anything to my specific Problem with Gnuplot in other Threads. I want to load a text file on Mac. When I tell Gnuplot to
load '/Users/name/Desktop/test.rtf'
it always says Cannot open script file.
I already made sure, that I'm in the right working directory (I guess):
pwd
gives /Users/name
The text file contains:
plot sin(x)
and the standard terminal I'm using is
terminal type is wxt 0 enhanced
I hope someone can help me with that, since I'm not experienced in using programs with the terminal, so I really don't know how to solve my Problem right here.
first of all thanks for your answer! So I just managed to find my mistake, it seems that it has to do something with the notation, since I'm working on a german Mac. So
load 'file'
makes Problems, while
load "file"
works fine for me. Unfortunately I still have the Problem, that
set terminal postscript eps enhanced
set output "/Users/name/Desktop/testplot 2.png"
set encoding default
p sin(x)
set terminal wxt 0 enhanced
gives me a file, that can't be opened and it says the file is probably damaged or the format is not supported by 'preview'. It is not a huge problem actually since I can save the plot manually from the wxt terminal, but I really don't understand what Gnuplot is doing on OS X...
I'm looking for a way to load a custom command to my gnuplot sessions. Often after playing around with a plot I want to output it to PDF, and continue working. This will look like:
set terminal pdf
set output 'somefilename.pdf'
replot
set terminal qt
replot
Currently the best I can do is put that in a separate file with the file name a variable instead of a string, define said variable in my session, then load said file. I'm wondering if I can load this script as a command that takes an argument, so I can do something like
exportpdf "myfile.pdf"
I think your your current method is already pretty good, but if you want you can fine-tune it a little bit:
If you are willing to keep storing the name of the file in a gnuplot variable FILENAME, then you can circumvent the need of an external file by using macros:
exportpdf="set term push; set term pdf; set output FILENAME; replot; set output; set term pop"
You can then save your current figure by executing
#exportpdf
If you want to give the filename as an argument you can create a script file exportpdf.gp
set term push
set term pdf
set output ARG1
replot
set output
set term pop
and define the string
exportpdf='call "exportpdf.gp"'
for example in your startup file. Then you can save your current figure to filename simply by executing
#exportpdf "filename.pdf"
if you want to define a custom "function", you could first construct the appropriate command and then evaluate it:
plotPdf(fname) = eval(sprintf("set terminal pdf;set output '%s';replot;set terminal qt;replot;", fname))
this definition can be then conveniently placed in the Gnuplot startup script so that it is automatically available
Is it possible to generate a .png output without generating a plot?. I have my data set that I have to draw in a .png to later on spc to my server.
So far all the examples I have seen use the 'plot' instruction which generates the plot.
Thanks in advance!
ok it took me a bit of playing with the command but got it to work.
all you gotta do is configure the output to be a .png file BEFORE doing the plot in the command order.
e.g: gnuplot -e 'set term png;set output"data_print.png";plot"calibration.dat"'
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.
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.
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.
Create your Datafile like this:
# X Y
10000.0 0.01
100000.0 0.05
1000000.0 0.45
And plot it with
$ gnuplot -p -e "plot 'filename.dat'"
There is a good tutorial: http://www.gnuplotting.org/introduction/plotting-data/
For future reference, I had the same problem
"warning: Skipping unreadable file"
under Linux. The reason was that I love using Tab-completing and in gnuplot this added a whitespace at the end that I did not really notice
gnuplot> plot "./datafile.txt "
I had the same issue when tried to open the file using Plot->Data filename... option provided in the version for Windows 7 (by the way, it worked fine on another computer with the same version of the OP system).
Then I tried to change directory and save the .plt file, but it didn't work either. Finally, I tried to tape manually as it was showed for Linux earlier in this queue of posts:
gnuplot > plot "./datafile.dat"
and it worked!
This error usually means the file couldn't be found.
Can you see the file from the command line?
Try specifying the full pathname.
check line ending type (use 0x0d).
is file open in another program?
do you have read access to it?
I was having the exact same issue. The problem that I was having is that I hadn't saved the .plt file that I was typing into yet. The fix: I saved the .plt file in the same directory as the data that I was trying to plot and suddenly it worked! If they are in the same directory, you don't even need to specify a path, you can just put in the file name.
Below is exactly what was happening to me, and how I fixed it. The first line shows the problem we were both having. I saved in the second line, and the third line worked!
gnuplot> plot 'c:/Documents and Settings/User/Desktop/data.dat'
warning: Skipping unreadable file c:/Documents and Settings/User/Desktop/data.dat
No data in plot
gnuplot> save 'c:/Documents and Settings/User/Desktop/myfile.plt'
gnuplot> plot 'c:/Documents and Settings/User/Desktop/data.dat'
Just go to the properties of your cmd.exe shortcut and change the 'start in' by adding the file name where you put all your '.txt' files.I had same problems and i put the whole file mane as 'D:\photon' in the 'start in' of the properties and it worked.Remember you have to put all your files in that folder otherwise you have to create many shortcuts for each data files.Sorry for late reply