Gnuplot Cannot open script file 'test.rtf' - gnuplot

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...

Related

gnuplot : writing out particular settings into a "header"

It would be handy to have gnuplot write particular settings to an output file, ideally in a .svg, because svg appears very well suited for that - so the image file and settings are all together - however, it appears this is not feasible directly in gnuplot.
Working within the wxt and svg terminals, and especially multiplot, I have been able to see how gnuplot might interface with the shell (for example):
! ls ; pwd ; echo $0, print sin(pi), show terminal. Trouble happens though when trying usual redirection such as > foo.txt and such - even starting a separate gnuplot session by script just to get the parameters. In particular, I found this interesting :
output is sent to STDOUT
print output is sent to '<stderr>'
... though I'm not sure what to do with that.
I could use e.g. ! cat gnuplot.inp | grep terminal >> gnuplot.svg, and dig into further awk/sed scripting, but before doing that it would help to know if I'm missing any small details in gnuplot first. Thanks.
PS a trivial question : why is the shell in gnuplot sh, when the plain-old linux terminal shell I am using is bash and SHELL=/bin/bash? I notice that shell drops the session into the shell from which gnuplot was executed - not sure if that will help the task.
1 The usual way to save current settings to a file is the command save "filename". There is a script in the gnuplot repository called gpsavediff (it may or may not be included in your distro's gnuplot package) that compares the saved values to the default settings and keeps only the ones that changed. From a gnuplot session under linux a typical use would be
... do a bunch of stuff to make a plot ...
save "| gpsavediff > myplot.gp"
... do a bunch more stuff ...
# recover original plot
reset session
load "myplot.gp"
To write specific lines or text to a file is much simpler than you show. For instance
.
set print "session.log" append
print "# This plot looked good on the screen."
print "# At this point the view angles were ", GPVAL_VIEW_ROT_X, GPVAL_VIEW_ROT_Z
print "# I save a PostScript copy to foo.ps"
set term push
set term postscript color
set output "foo.ps"
replot
unset output
set term pop
...
When invoking a shell, gnuplot uses the libc library function popen(). The gory details of popen() are somewhat system dependent but you probably have a man page for it.
gpsavediff script here

Changing gnuplot x11 output defaults

I am using gnuplot over ssh (-X) and due to different screen resolution issues, my x11 output window has minuscule fonts. I want to access the .Xdefaults file as mentioned in documentation but cannot locate it. This question GNUPLOT_DRIVER_DIRECTORY pointed towards some solution but I don't want to input it every time. Can someone help me find a permanent fix for font sizes?
What is your default terminal ? I think it shoulds be xterm, to have x11 as defaults.
shell> echo $TERM
What is yout default gnuplot terminal display ?
gnuplot> show term
Instruction in ~/.Xdefaults have a special syntax (some example in linuxcertif.com/man/1/gnuplot/ ). But i think that's not what you want to do. This is more for 'fine tuning'. And i think it will only be effective if your default terminal is allready x11.
gnuplot*pointsize: 2
gnuplot*background: white
gnuplot*textColor: black
Anyway, it is better to use gnuplot with a text file : file.gp where you put your commands. Then just put in the beginning of your file :
set term x11 font "arial,15"
And execute your file with :
shell> gnuplot file.gp -
do not forget the 'dash' '-' at the end of the command, so that you can continue to put command in the gnuplot prompt to debug additional command.

gnuplot reseting terminal to default output

In gnuplot, using the commands
set term pdf
set out 'filename.pdf'
plot sin(x)
allows me to write the image to a pdf. After doing so, how do I reset the output so that plot sin(x) creates the image using the built-in gnuplot display (as it does without ever have using set out in the first place).
Right now I can only acheive this by restarting gnuplot. The reset command does not seem to help. Thanks all!
In addition to the other answer, you could do:
set term pop
set output #reset standard output stream
In general, you can save the terminal settings you're currently working one using:
set term ... #what you want to save
set term push
set term ... #temporary terminal
set term pop #restore the terminal settings that you "pushed"
However, as documented in help set terminal:
The command set term push remembers the current terminal including its
settings while set term pop restores it. This is equivalent to save term
and load term, but without accessing the filesystem. Therefore they can be
used to achieve platform independent restoring of the terminal after printing,
for instance. After gnuplot's startup, the default terminal or that from
startup file is pushed automatically. Therefore portable scripts can rely
that set term pop restores the default terminal on a given platform unless
another terminal has been pushed explicitly.
Assuming you have the X11 version of gnuplot installed. Set the terminal back to x11 and reset the output
set term x11
set out

How to create a data file for 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.
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

gnuplot and "Failed to initialize wxWidgets"

i want to plot120 files with gnuplot.
plot '18205.plot' u 1:3 w l t '18205' , '18208.plot' u 1:3 w l t '18208'
Failed to initialize wxWidgets.
warning: Warning - difficulty fitting plot titles into key
warning: Too many axis ticks requested (>1e+01)
warning: Too many axis ticks requested (>1e+01)
warning: Too many axis ticks requested (>6)
the files looking like
21 4 0.865671
22 4 0.894175
23 4 0.921895
24 4 0.949053
25 4 0.975792
26 4 1.00147
27 4 1.02577
28 4 1.05008
Apparently this is it failing to detect a terminal it likes. On my Debian stable "gnuplot 4.4 patchlevel 0" I get an identical error until I add some:
set terminal png
...at which point it works fine. Raaage!
The important bit is this:
Failed to initialize wxWidgets.
This means that gnuplot couldn't open a window to plot using wxWidgets.
Be sure that the terminal where you are running gnuplot can open windows in X. You can do that by typing echo $DISPLAY in the terminal (or !echo $DISPLAY from within gnuplot) and checking if it's not empty and if it makes sense (usually this means a value of :0.0. If it should be anything different, you should know that because you have set it up that way ;) ).
Setting the right X permissions is also necessary if you are running gnuplot as a different user (or on a different host e.g. via ssh) than the one running the graphic environment. in a secure environment xhost + would do, but if you are on a network and specially not behind a firewall, xhost server-running-gnuplot.domain would be a much wiser choice.
I was getting the same errors. However, I realised that I did not have X permissions in my current terminal window. This would explain why switching terminal formats to non-X (ie. jpg/png) worked for the guys above as well.
As the warning suggest you probably have too many keys in you plot. Try leaving away the titles and set key off.
Also you might want to take a look at iterations like in THIS blog at the bottom. This would clean up your script quite a lot.
You might want to ask yourself if you really want to plot 120 lines in a singe plot!?
just set area size, such as:
set terminal png size 1500 1200
and then plot
I was getting the same error. Switching to a different output format fixed it for me.
To have your graph be a jpg:
set term jpeg
To see all possible output formats:
help term

Resources