Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a pdf image to a gnuplot plot?

Tags:

gnuplot

I have an image in PDF format and I want to add to an existing gnuplot plot.

My current code is like:

set terminal postscript eps enhanced color solid font "Nimbus Roman No9 L" 35
set output '|epstopdf --filter > Patterns.pdf'
set size 1.8,1.8
set style data histogram
set style histogram cluster gap 1
plot 'Patterns.dat' using ($2/2.90):xtic(1) title col fs pattern 3

and the pdf file is stored in image.pdf.

like image 902
Mojtaba Avatar asked Jul 28 '26 12:07

Mojtaba


1 Answers

It can be done, at least with the epslatex terminal. First, for my example, I am going to generate a pdf file which is a gnuplot-generated figure:

set term epslatex standalone
set output "plot1.tex"
plot sin(x)

Now, outside gnuplot, I generate the pdf file (named plot1.pdf):

pdflatex plot1.tex

which looks like this:

enter image description here

To embed this into a gnuplot graph, I use again the epslatex terminal and embed plot1.pdf as I would do with any pdf file in a latex document, using the \includegraphics[]{} environment, with a gnuplot label:

set term epslatex standalone
set output "plot2.tex"
set label at graph 0.75,0.25 '\includegraphics[width=2cm]{plot1.pdf}'
plot x

And, again run pdflatex:

pdflatex plot2.tex

that generates plot2.pdf, which looks like this:

enter image description here

By changing the location of the label you can change the location of the embedded pdf; by changing the width you can change, guess what, the width of the embedded pdf.

like image 176
Miguel Avatar answered Jul 30 '26 05:07

Miguel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!