[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: pdflatex + gnuplot?
From: |
Reza Housseini |
Subject: |
Re: pdflatex + gnuplot? |
Date: |
Thu, 27 Sep 2012 07:39:03 +0200 |
On Thu, Sep 27, 2012 at 12:47 AM, Leo Butler <address@hidden> wrote:
> 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
>
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://mailman.cae.wisc.edu/listinfo/help-octave
Hello Leo
Another nice way to make pdf/latex files from plots is to use the
matlab2tikz function: https://github.com/nschloe/matlab2tikz
It fully supports Octave is easy to use and makes beautiful plots.
Cheers Reza