Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I would like to create a graphic with gnuplot for example and import it to latex to implement it in a text. The problem is that its caption, which I created with latex, has a different font, size etc. than the labeling of the axes which were created by gnuplot.

Now I thought I might create an image via gnuplot saved as tikz, so that, when I include it in latex, the labeling's font etc., changes to the standards of the rest of my document in latex. At the end I would like to see a PDF format file which contains my text and the graphic with the same font-/ size etc.

share|improve this question
3  
Looks like you are searching for the standalone documentclass… –  Benedikt Bauer Oct 29 '13 at 14:56
2  
Why don't you call gnuplot from within tikz? Then everything should be consistent. Examples for tikz and pgfplots (search for gnuplot, or 4th example). –  Jost Oct 29 '13 at 15:23

2 Answers 2

Example

Plotting the von Neumann entropy of a two-level spin system, which was prepared in a state of superposition.

Gnuplot code

#!/usr/bin/env gnuplot

reset
set terminal tikz standalone
set output "entropy.tex"

unset key
set grid
set xrange [0:1]
set samples 1000
set title 'Von Neumann entropy'
set xlabel '$\lambda$'
set ylabel '$S(\lambda)$'

plot -( 1./2. * (1 + sqrt(1-2*x+2*x**2)) * \
    log( 1./2. * (1 + sqrt(1-2*x+2*x**2)) ) \
    + \
    1./2. * (1 - sqrt(1-2*x+2*x**2)) * \
    log( 1./2. * (1 - sqrt(1-2*x+2*x**2)) ) )

LaTeX Output

Compile the produced entropy.tex using pdflatex. You now get the correct LaTeX fonts.

enter image description here

share|improve this answer

I have been using this python script, which is very easy to use. https://github.com/oso/tikz2pdf

I think the README explains most of the part. Say if you have a tikz file myfig.tikz, you just type in terminal

tikz2pdf myfig.tikz

and a pdf file myfig.pdf will be generated in the same folder. If you want to have the pdf updated once the tikz file is modified, you can use this command:

tikz2pdf -ws myfig.tikz

I only need to change the default viewer to open to use it on a mac, and on a linux machine you can put an alias in your .bashrc

alias open=xdg-open

and you are good to go.

share|improve this answer
1  
Link-only answers are not that helpful. Could you provide more detail in terms of the interface, how one would use it, and perhaps show an example? –  Werner Oct 30 '13 at 1:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.