TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am spawning a .eps file with octave by using this .m file:

function dummy
xlim([0 81]);
x = [0:0.01:81];
plot (x,y*1.85,"-;aaaa;",'linewidth',2,x,y*1.00,"-;bbbb;",'linewidth',2,x,y*1.25,"-;cccc;",'linewidth',2,x,x/2,"-;dddd;",'linewidth',2);
legend ("location", "northwest");
xlabel ("kkkk");
ylabel ("yyyy");
set (gca (), "xtick",[]);
set (gca (), "ytick",[]);
set (gca (), "fontname","DejaVuSans");
print('-dtex', 'dummy.tex');

and including it with this LaTeX "container":


    % You can run this by typing the following commands:
    %    latex 2dplot.tex
    %    dvips -o 2dplot.ps 2dplot.dvi


% The syntax of the "psfrag" command is:
%    \psfrag{tag}[<posn>][<psposn>][<scale>][<rot>]{replacement}
% See the file pfgguide.ps for full documentation.

\psfrag{bbbb}{\small{$s_1 \cdot y$}}
\psfrag{cccc}{\small{$s_2 \cdot y$}}
\psfrag{dddd}{\small{$k(\Sigma + n + g)$}}


But the psfrag replacements show up at bottom left corner of the page.
Running latex ./dummy.tex does not yield any errors.

share|improve this question
up vote 3 down vote accepted

The replacements not showing on the actual picture are OK. From the psfrag manual:

When viewing the output with a DVI previewer such as dviwin or xdvi, a vertical list of the replacements will be placed on the left side of each figure. This list allows you to check the typesetting of your replacements; it disappears in the final PostScript version. Unfortunately, DVI drivers are incapable of placing the PSfrag replacements on top of the figure, so for that you will need to print it or use a PostScript previewer like GhostView

You should convert your dvi to ps or pdf or print it in order for the replacements to apply.

share|improve this answer
You'll also see the same behavior when using TikZ or pstricks to draw images with TeX text included in the image. A DVI previewer won't position the text properly, but a postscript or PDF version will be fine. This is due to the limitations of the DVI previewers. – Ken Bloom May 5 '11 at 15:08

As for an alternative to Octave, here is how I would do in R:

x <- seq(0, 81, by=.01)
y <- x^.5+x^.4+x^.3+x^.2+x^.1
dat <- data.frame(x, y1=y*1.85, y2=y, y3=y*1.25, y4=x/2)

lp <- xyplot(y1+y2+y3+y4~x, dat, type="l", xlab="k", ylab="y",
             main="Tour title here",
             col = c('blue', 'red', 'green', 'cyan'),
             key=list(x=0.05, y=0.95, text=list(c(expression(y), 
                                                  expression(s[1] %.% y), 
                                                  expression(s[2] %.% y), 
                                                  expression(k(Sigma + n + g)))),
                      lines=list(lty=1, col=c('blue','red','green','cyan'))))

It can be saved as PDF with

pdf("yourfilename.pdf", width=5, height=5)

or quite in the same manner with the postscript() function for EPS output.

Here is the result:

enter image description here

share|improve this answer
ocatve is not capable of inserting greek letters and fun, therefore I wanted to replace the dummy labels aaaa, bbbb and so on with the correct greek formule – drahnr May 5 '11 at 12:58
@drahnr I missed that point. Would you like me to give you the R syntax for producing such a plot? – chl May 5 '11 at 13:02
even if I use your print(...) , I still get the PSfrag replacments all rendered at the bottom right of the dvi and the legend gets not adjusted as desired – drahnr May 5 '11 at 13:06
give me whatever you have :> I am thankful for everything, maybe point me to a R howto :) thank you – drahnr May 5 '11 at 13:06
@drahnr While we're in (and because I read another comment of yours), you can change line thickness with lwd= ($>1$ means larger) and line type with lty= (1=solid, 2=dashed, 3=dotted, 4=dash-and-dot). It might help if this is for a BW paper. Be sure to add this in both the legend (inside the key list) and the call to xyplot. Should you want to add a grid layout, use type=c("l", "g"). Good luck! – chl May 5 '11 at 16:14

Generally, I'd be inclined to alter a graphic item by altering the code that created it. If that cannot be done, I'd use inkscape on it. These two options yield a graphic that can be used in any application (e.g. presentation application, web application), and not just in latex. So, heresy that this may be in this group, I'd advise dropping your work with psfrag, seeing as you've had difficulties.

share|improve this answer
Postprocessing with inkscape is uggly, in case the grpahs change in the future I'll have to redo it anytime even only a tiny bit changes. Not an option. It is for a paper so.. – drahnr May 5 '11 at 13:00

Your Answer


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.