Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Gnuplot and epslatex

1,150 views
Skip to first unread message

Gaius Verres

unread,
Jul 25, 2011, 3:22:20 AM7/25/11
to
Hi,

I have problems embedding a gnuplot multiplot in LaTeX (gnuplot 4.4.3,
MikTeX 2.9, Windows XP, SP3):

<code>
set terminal epslatex color standalone

set output 'multiplot.tex'

f(x)=x**2
g(x)=x**3
h(x)=x**4

set multiplot

set size 1.5,1.0
set origin 0.0,2.158
set bmargin 0
set tmargin 1
set format x ""
plot f(x)

set size 1.5,1.0
set tmargin 0
set bmargin 1
set origin 0.0,1.158
plot g(x)

set size 1.5,1.0
set tmargin 0
set bmargin 1
set origin 0.0,0.2
plot h(x)

unset multiplot
</code>

What do I do:

1. run the above script
2. run multiplot.tex
3. open the created PS file and convert it to EPS via GSView 4.9
4. convert the EPS to pdf via epstopdf

Well now, I have the following problem: I can see only a *part* of the
plot in the reuslting PDF file.

5. integrate the PDF file in my document, run pdflatex

Any idea what I can do?

I tried to import the EPS in Inkscape 0.48.1 but it also recognizes
onyl a part of the plot and I normally "lose" the LaTeX fonts. Some
time ago, I found out that I can install the LM fonts
http://www.gust.org.pl/projects/e-foundry/latin-modern/download to
overcome that. But now even that does not work.

Of course I could use the LaTeX code generated by gnuplot directly (or
gnuplottex), i.e. the plot itself as an EPS and the axis as a LaTeX
but publishers want to have EPS/PDF for the *whole* plots and LaTeX
files which are as simple as possible without any further packages.

Christoph Bersch

unread,
Jul 25, 2011, 4:41:18 AM7/25/11
to
Hi,

On 25.07.2011 09:22 Gaius Verres wrote:
>
> set size 1.5,1.0
[...]

> Well now, I have the following problem: I can see only a *part* of the
> plot in the reuslting PDF file.

From the documentation of "set size":

set size <XX>, <YY> scales the plot itself relative to the size of the
canvas

So your plot is bigger than the canvas.

Christoph

Gaius Verres

unread,
Jul 25, 2011, 5:01:08 AM7/25/11
to
Hi,

well, I have tried to change every "set size 1.5,1.0" to "set size
0.2,0.2" but that didn't help.

Or have I understood something wrong?


Christoph Bersch

unread,
Jul 25, 2011, 6:15:47 AM7/25/11
to

You also have problem with some other settings:

set origin 0.0,2.158 # this is outside the canvas
set bmargin 0 # this crops the xlabels

Christoph

Gaius Verres

unread,
Jul 25, 2011, 7:24:10 AM7/25/11
to
OK, I have changed the the original file to:

<code>
set terminal epslatex color standalone

set output 'multiplot.tex'

f(x)=x**2
g(x)=x**3
h(x)=x**4

set multiplot

set origin 0.0,0.6
set size 0.8,0.4


set format x ""
plot f(x)

set origin 0.0,0.3
set size 0.8,0.4
plot g(x)

set origin 0.0,0.0
set size 0.8,0.4
plot h(x)

unset multiplot
</code>

The created PDF seems to be OK.

But if I want to use the EPS file named multiplot.eps (some publishers
require EPS) in LaTeX the resulting PS file does not contain the
graphics.

<code>
\documentclass{scrartcl}
\usepackage{graphicx}
\begin{document}
\begin{figure}
\centering
\includegraphics[scale=0.2]{multiplot}
\caption{multiplot}
\end{figure}
\end{document}
</code>

There is only: "Figure 1: multiplot" and the page number.

Gaius Verres

unread,
Jul 25, 2011, 9:32:34 AM7/25/11
to
There's also the same problem if I want to use overpic:

<code>
\documentclass[twoside,paper=a4,DIV12]{scrartcl}
\usepackage{graphicx}
\usepackage[rel]{overpic}

\begin{document}

\begin{overpic}[scale=1.0,unit=1mm,grid]
{multiplot}
\put(40,50){\includegraphics[scale=0.2,angle=00] {graph1}}
\end{overpic}

\end{document}
</code>

I can see graph1 in the resulting PS but not multiplot. What can I do?

sfeam

unread,
Jul 25, 2011, 11:09:33 AM7/25/11
to
Gaius Verres wrote:

> OK, I have changed the the original file to:
>
> <code>
> set terminal epslatex color standalone
>
> set output 'multiplot.tex'
>
> f(x)=x**2
> g(x)=x**3
> h(x)=x**4
>
> set multiplot
>
> set origin 0.0,0.6
> set size 0.8,0.4
> set format x ""
> plot f(x)
>
> set origin 0.0,0.3
> set size 0.8,0.4
> plot g(x)
>
> set origin 0.0,0.0
> set size 0.8,0.4
> plot h(x)
>
> unset multiplot
> </code>
>
> The created PDF seems to be OK.


PDF? Where did PDF come from?


> But if I want to use the EPS file named multiplot.eps (some publishers
> require EPS) in LaTeX the resulting PS file does not contain the
> graphics.
>
> <code>
> \documentclass{scrartcl}
> \usepackage{graphicx}

Maybe you need \usepackage[pdftex,dvips]{graphicx} ?
Is there an error message in the TeX log file?

James Waldby

unread,
Jul 25, 2011, 4:30:35 PM7/25/11
to

One finds it difficult to say. None of your previous messages mentioned
graph1, and you don't tell where it came from. Given the latex above,
I wouldn't expect to see any graph other than whatever is in your
graph1.eps file.

--
jiw

James Waldby

unread,
Jul 25, 2011, 4:46:44 PM7/25/11
to
On Mon, 25 Jul 2011 04:24:10 -0700, Gaius Verres wrote:

> OK, I have changed the the original file to:

[snip gnuplot code]


>
> The created PDF seems to be OK.
>
> But if I want to use the EPS file named multiplot.eps (some publishers
> require EPS) in LaTeX the resulting PS file does not contain the
> graphics.

[snip latex code]


> There is only: "Figure 1: multiplot" and the page number.

You might try some other viewer. I ran the gnuplot & latex
from your post, and used gsview ps-to-eps option as you said in
OP, and on my linux system the result viewed ok, with 3 graphs
and their Y axis labels, etc, in gv 3.6.2 and ok in gsview 4.9
and ok at shrink factors 4 thru 9 in xdvi 22.84.14, but disappeared
at shrink factors 1 thru 3 in xdvi and when left or right mouse
button was pressed to magnify the xdvi view.

--
jiw

Gavin Buxton

unread,
Jul 25, 2011, 7:32:51 PM7/25/11
to
Might I suggest simply making your figure as an eps file and adding it
to latex. This will satisfy the publishers (presumably Physical Review
or Europhys?).

You can generate your images in whatever format you want and then
convert them later. I usual generate basic postscript images (when
using gnuplot) and then copy them into a new file in gimp - I label
subplots a, b, etc... in gimp. Then save as an eps. This way as long
as you can see you figures in gimp you should be good as it will save
it as an image file.

To include them in latex I use:

\usepackage{epsfig}

\newcommand{\puteps}[4]{
\rotatebox{#1}{\resizebox{#2}{#3}{{\includegraphics{#4}}}}
}


At the top of my file, and then at the end (after my bibliography)

\newpage

\begin{center}
\begin{figure}
\puteps{0}{500pt}{!}{figure1.eps}
\end{figure}
Figure 1.
\end{center}

This allows me to rotate (especially useful if including ps file
directly as you'll need to rotate by 90) and resize the images in
latex to get the right effect. Hope this helps.....

Gaius Verres

unread,
Jul 26, 2011, 5:25:07 AM7/26/11
to
Sorry for the confusion!

What I meant with PDF: With my above-mentioned script I created an EPS
and a LaTeX file. When I run this LaTeX file I can get a PS file which
I convert to EPS with GSView.

This EPS file (multiplot.eps) can be converted to PDF (multiplot.pdf)
via epstopdf. If I use this PDF for the following

<code>
\documentclass{scrartcl}
\usepackage{graphicx}
\begin{document}
\begin{figure}
\centering
\includegraphics[scale=0.2]{multiplot}
\caption{multiplot}
\end{figure}
\end{document}
</code>

then I get a PDF with the figure. That's fine.

But if I just take the EPS and create a PS with the above-mentioned
code I have "There is only: "Figure 1: multiplot" and the page number.
".

Concerning "graph1": It is an arbitrary EPS file, but not
"multiplot.eps"

Christoph Bersch

unread,
Jul 26, 2011, 5:51:33 AM7/26/11
to

It is a bit difficult to follow your exact workflow. Here is what I
understood from what you are doing (and this works for me!):

Your code from
<2fae80d3-953b-4628...@l18g2000vbe.googlegroups.com>:

<file multiplot.gp>


set terminal epslatex color standalone

set output 'multiplot.tex'

f(x)=x**2
g(x)=x**3
h(x)=x**4

set multiplot

set origin 0.0,0.6
set size 0.8,0.4
set format x ""
plot f(x)

set origin 0.0,0.3
set size 0.8,0.4
plot g(x)

set origin 0.0,0.0
set size 0.8,0.4
plot h(x)

unset multiplot
</file>

<file usemultiplot.tex>


\documentclass{scrartcl}
\usepackage{graphicx}
\begin{document}
\begin{figure}
\centering
\includegraphics[scale=0.2]{multiplot}
\caption{multiplot}
\end{figure}
\end{document}

</file>


gnuplot multiplot.gp
latex multiplot.tex
dvips multiplot.dvi
ps2eps multiplot.ps
epstopdf multiplot.eps

now you have both a .eps and a .pdf version of your plot. Now both the
following inclusions work for me:

pdflatex usemultiplot.tex
-> this gives you a pdf with the embedded multiplot.pdf

latex usemultiplot.tex
dvips usemultiplot.dvi
-> this gives you a ps with the embedded multiplot.eps

Christoph

Gaius Verres

unread,
Jul 26, 2011, 6:25:53 AM7/26/11
to
On 26 Jul., 11:51, Christoph Bersch <use...@bersch.net> wrote:
> It is a bit difficult to follow your exact workflow. Here is what I
> understood from what you are doing (and this works for me!):
>
> Your code from
> <2fae80d3-953b-4628-8517-6b70bd313...@l18g2000vbe.googlegroups.com>:
> ...

>
> gnuplot multiplot.gp
> latex multiplot.tex
> dvips multiplot.dvi
> ps2eps multiplot.ps
> epstopdf multiplot.eps
>
> now you have both a .eps and a .pdf version of your plot. Now both the
> following inclusions work for me:
>
> pdflatex usemultiplot.tex
> -> this gives you a pdf with the embedded multiplot.pdf

So far, this works for me, too.

> latex usemultiplot.tex
> dvips usemultiplot.dvi
> -> this gives you a ps with the embedded multiplot.eps

Now, I only get "Figure 1: multiplot" and the page number.

Christoph Bersch

unread,
Jul 26, 2011, 7:03:06 AM7/26/11
to

Hmm, now I do not really know what else to look for:

- Do you get any warnings during these two compilations (latex and dvips)?

- Does it work when you convert the .ps file to .pdf with
ps2pdf usemultiplot.ps

- When you open the file usemultiplot.ps with a texteditor, search for a
line containing the string multiplot.eps. This should also show, if the
file was embedded successfully.

- Which viewer do you use?

no more ideas, what could cause the problem...
Christoph

Gaius Verres

unread,
Jul 26, 2011, 7:13:14 AM7/26/11
to
On 26 Jul., 13:03, Christoph Bersch <use...@bersch.net> wrote:
> - Do you get any warnings during these two compilations (latex and dvips)?

No. The log file ends with "Output written on usemultiplot.dvi (1
page, 428 bytes)."

> - Does it work when you convert the .ps file to .pdf with
> ps2pdf usemultiplot.ps

No, then the PDF is empty, too.

> - When you open the file usemultiplot.ps with a texteditor, search for a
> line containing the string multiplot.eps. This should also show, if the
> file was embedded successfully.

"%%BeginDocument: multiplot.eps"

> - Which viewer do you use?

GSview 4.9, Ghostscript 9.02, Windows XP, SP3, MikTeX 2.9,
TexnicCenter 1.0.

Ingo Thies

unread,
Jul 26, 2011, 7:24:12 AM7/26/11
to
On 25.07.2011 09:22, Gaius Verres wrote:

> Of course I could use the LaTeX code generated by gnuplot directly (or
> gnuplottex), i.e. the plot itself as an EPS and the axis as a LaTeX
> but publishers want to have EPS/PDF for the *whole* plots and LaTeX
> files which are as simple as possible without any further packages.

One question for further understanding: Does the publisher want all the
sub-plots separately or the whole multiplot array as a single .eps?

If the former, then I would generate the subplots as separate .eps files
(e.g. by putting a set output "fig1a", set output "fig1b" etc. before
each plot command) and submit them together with the manuscript as a
tarball. For the reviewer you can fit them together with multiplot.

In the latter case (i.e. all-in-on) I would just use multiplot. BTW did
you consider the explicit positioning via set {r,l,t,b}margin screen
{coordinates}? This allows you exact seamless fitting of the subplots
without bothering with set size and set origin.


Best wishes,

Ingo

Gaius Verres

unread,
Jul 26, 2011, 9:11:19 AM7/26/11
to
On 26 Jul., 13:24, Ingo Thies <ingo.th...@gmx.de> wrote:
> ...

> One question for further understanding: Does the publisher want all the
> sub-plots separately or the whole multiplot array as a single .eps?
>
> If the former, then I would generate the subplots as separate .eps files
> (e.g. by putting a set output "fig1a", set output "fig1b" etc. before
> each plot command) and submit them together with the manuscript as a
> tarball. For the reviewer you can fit them together with multiplot.
>
> In the latter case (i.e. all-in-on) I would just use multiplot. BTW did
> you consider the explicit positioning via set {r,l,t,b}margin screen
> {coordinates}? This allows you exact seamless fitting of the subplots
> without bothering with set size and set origin.

OK, how do I use this "set {r,l,t,b}margin screen {coordinates}"? I
couldn't found it in the docu.

Ingo Thies

unread,
Jul 26, 2011, 9:43:08 AM7/26/11
to
On 26.07.2011 15:11, Gaius Verres wrote:

> OK, how do I use this "set {r,l,t,b}margin screen {coordinates}"? I
> couldn't found it in the docu.

In the gnuplot.pdf of version 4.4

http://www.gnuplot.info/documentation.html

it is described on page 119f. Basically, if you want to divide the
screen onto two plots stacked above each other with 20% of the space is
left for the x and y axis labels (just as an example), the commands look
like

plot 1 (top)
set lmargin at screen 0.2
set rmargin at screen 1.0
set bmargin at screen 0.6
set rmargin at screen 1.0

plot 2 (bottom)
set lmargin at screen 0.2
set rmargin at screen 1.0
set bmargin at screen 0.2
set rmargin at screen 0.6

The space of 0.2 screen (or canvas) units to the left and below is
reserved for the labels in this example. You have to adjust these label
margins yourself (0.2 is just for illustration here and might be way too
large), as well as the canvas dimensions. In your case, there are more
frames the plotting canvas is to be divided into.

Since I had these multiplot problems earlier, I have written some
gnuplot scripts that make this a bit easier (but basically makes use of
this explicit margin placement). See

http://www.astro.uni-bonn.de/~ithies/gnuplot/mplayout/

including an example driver with the required variables set (just play
around with them).

It's still under development, and many improvements may be possible, but
maybe it's of some help to you.

Best wishes

Ingo

Gaius Verres

unread,
Aug 1, 2011, 5:19:50 AM8/1/11
to
Thank you very much for the many answers!

In the end, I tried something like this, which works fine:
http://kpwu.wordpress.com/2007/11/20/gnuplot-make-a-multiplot-3-stacked-plots/

Concerning overpic, I directly generate PDF and then crop the file
with briss.

Gavin Buxton

unread,
Aug 2, 2011, 8:18:43 AM8/2/11
to
Looks good!

You should label the axis and add labels a, b, and c to the subplots.


0 new messages