From help-octave-request at bevo dot che dot wisc dot edu Tue Dec 5 20:11:45 2000 Subject: gnuplot out fails to get sent to file From: Phil Cummins To: help-octave at bevo dot che dot wisc dot edu Date: Wed, 6 Dec 2000 11:38:28 +0900 Hello, I'm using octave-2.0.16 with gnuplot-3.8c. I have tried using the psfig function someone recently posted to this list, but have modified it slightly to use graw for sending commands to gnuplot. It's a very simple function which sets gnuplot's ouput to postscript and sends it to a file: ## Usage: psfig(filename) ## Puts figure into ps file function psfig(filename) ## Add .ps if not there already if !index(filename,".") filename = sprintf("%s.ps",filename); endif graw(sprintf("set output \"%s\"\n",filename)); graw("show output;\n"); # What is the output now? graw("set style line 1 lw 5\n"); graw("set style line 2 lw 5\n"); graw("set style line 3 lw 5\n"); graw("set style line 4 lw 5\n"); graw("set style line 5 lw 5\n"); graw("set style line 6 lw 5\n"); graw("set style line 7 lw 5\n"); graw("set terminal postscript portrait color \"Helvetica\" 14\n"); graw("show output;\n"); # And what is the output now? - should be the same... graw("set size 1,.5\n"); graw("replot\n"); graw("set size 1,1\n"); graw("set term x11\n"); graw("set output \n"); endfunction graw("set term x11\nset output\n"); replot; endfunction I put in the two graw("show output\n"); statements for debugging this problem. The output from this function looks like: octave:350> psfig("fcplt"); output is sent to 'fcplt.ps' output is sent to STDOUT %!PS-Adobe-2.0 %%Creator: gnuplot 3.8c patchlevel pm3d 6 ... followed by lots more postscript. My question is, why does the outout get set back to STDOUT before the postscript is sent? The psfig function tells gnuplot to set the output to a file, send the postscript to that file, and only after that reset the ouput to STDIN. If I remove the lines graw("set term x11\n"); graw("set output \n"); at the end the psfig function, I can finally get the postscript sent to the file, but only if I run it twice (i.e., postscript finally gets written to the file the second time). I get similar behavior with the figfig() function recently posted to this list. Any suggestions gratefully appreciated. Thanks, -- --------------------------------------------------------------------- Phil R Cummins cummins at jamstec dot go dot jp Frontier Research for Subduction Dynamics tel(i/d):81/0-468-67-3393 JAMSTEC, 2-15 Natsushima-cho fax(i/d):81/0-468-67-3409 Yokosuka 237-0061, Japan ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------