help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: pdflatex + gnuplot?


From: Leo Butler
Subject: Re: pdflatex + gnuplot?
Date: Wed, 26 Sep 2012 18:47:06 -0400
User-agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/23.4 (gnu/linux)

Ben Abbott <address@hidden> writes:

> On Sep 26, 2012, at 5:23 PM, Leo Butler wrote:
>
>> Ben Abbott <address@hidden> writes:
>> 
>>> On Sep 26, 2012, at 4:01 PM, Leo Butler wrote:
>>> 
>>>> I am using octave 3.6.2 and gnuplot 4.6.0, both from debian testing. The
>>>> documentation for print states
>>>> 
>>>> ,----
>>>> |          `pdflatex'
>>>> |                Generate a LaTeX (or TeX) file for labels, and eps/ps/pdf
>>>> |                for graphics.  The file produced by `epslatexstandalone'
>>>> |                can be processed directly by LaTeX.  The other formats
>>>> |                are intended to be included in a LaTeX (or TeX)
>>>> |                document.  The `tex' device is the same as the
>>>> |                `epslatex' device.  The `pdflatex' device is only
>>>> |                available for the FLTK graphics toolkit.
>>>> `----
>>>> 
>>>> The cairolatex terminal is capable of generating nice pdf/eps+latex
>>>> files, with the only change in code being eps -> pdf.
>>>> 
>>>> I realize that octave provides an abstraction layer above gnuplot/fltk,
>>>> but perhaps there is some really easy way to implement this in octave as
>>>> it stands without patching code? Am I right- or wrong-headed?
>>>> 
>>>> Leo
>>> 
>>> You can use the drawnow() function to output a gnuplot plot-stream and then 
>>> modify the plot-stream to use the cairolatex.  I haven't tested the 
>>> instructions below, so some modification may be needed.
>>> 
>>> (1) Produce your plot
>>> (2) drawnow ("x11", "/dev/null", false, "plotstream.gp")
>>> (3) Edit plotstream.gp and change "set term x11..." to "set term cairolatex 
>>> ...", also specify a new output file.
>>> (4) Run gnuplot and load plotstream.gp
>>> 
>>> Ben
>> 
>> That does work, thanks.
>> 
>> Is it possible to direct the gnuplot plot-stream to a string? I don't
>> know how to rebind stdout in octave.
>> 
>> Leo
>
> I don't think so.  But you can read the result using fread (or another i/o 
> function).
>
> Ben

Ok, thanks. Here is code I came up with

function print2pdflatex (file)
  [fid,name,msg]=mkstemp("/tmp/octave-pdflatex-XXXXXX",true);
  drawnow("x11",file,false,name);
  system(sprintf("sed -r -e '2{s|.+|set terminal cairolatex pdf linewidth 4 
color|}' %s | gnuplot",name));
endfunction

Obviously, I could query the linewidth and color properties, but
otherwise this is fine for me.

Thanks for your suggestion.

Leo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]