From octave-sources-request at bevo dot che dot wisc dot edu Thu Sep 14 05:17:14 2000 Subject: Setting the linewidth (the hard way) From: Mats Jansson To: octave-sources at bevo dot che dot wisc dot edu Date: Thu, 14 Sep 2000 12:17:02 +0200 I wrote a function that returns the last plot command from gnuplot. It can be used to set the line width etc. octave:176> type lastplotcmd lastplotcmd is the user-defined function defined from: /home/mj/lastplotcmd.m ## function cmd = lastplotcmd () ## ## Return the last plot command from gnuplot. ## Mats Jansson , Sep 9, 2000 function cmd = lastplotcmd () tmpfile = tmpnam (); graw (sprintf ("save '%s'\n", tmpfile)); ## The last plot command (if any) is located in the second last line ## in tmpfile. (At least in gnuplot 3.7 and 3.8c) t1 = clock; maxtime = 10; while (1), [fid, msg] = fopen (tmpfile, "r"); if (fid != -1 || etime (clock (), t1) > maxtime), break; endif endwhile if (fid == -1), error (msg); endif a = fread (fid); fclose (fid); unlink (tmpfile); nl = find (a == 10); ## The positions of newline. cmd = ""; if (! isempty (nl)), lr = length (nl); ## Add a check here b = a(nl(lr - 2) + 1:nl(lr - 1) - 1); b = setstr (b'); lg = length (gnuplot_command_plot); if (length (b) >= lg && strcmp (gnuplot_command_plot, b(1:lg))), cmd = b; endif endif endfunction octave:177> plot (1:10,1:10) octave:178> lastplotcmd ans = pl "/tmp/oct-ueewee" t "line 1" octave:179> hold on octave:180> plot (1:10,2:11) octave:181> lastplotcmd ans = pl "/tmp/oct-ueewee" t "line 1","/tmp/oct-T1JnDO" t "line 2" octave:182> graw ('pl "/tmp/oct-ueewee" t "line 1" lw 3,"/tmp/oct-T1JnDO" t "line 2" lw 5\n') ## Set the line widths to 3 and 5 octave:183> -- Mats Jansson phone (+47) 55 22 52 02 Research and Development fax (+47) 55 22 52 99 Nera Networks AS, P.O.Box 7090, N-5020 Bergen, Norway ----------------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.che.wisc.edu/octave/octave.html How to fund new projects: http://www.che.wisc.edu/octave/funding.html Subscription information: http://www.che.wisc.edu/octave/archive.html -----------------------------------------------------------------------