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'm trying to use the spy glass in Tikz, but for some reason my zoom area is always empty and (some) graphs tend to disappear when I use spy. I've updated all my packages etc. through the updater by MikTeX but this didn't solve anything. The code I use:

\documentclass{article} 
\usepackage{pgfplots} 
\usetikzlibrary{spy} 

\begin{document}  
\begin{tikzpicture}
[spy using outlines={rectangle, magnification=3,connect spies}] 

\begin{axis}[grid=major,no markers,domain=-5:5,enlargelimits=false] 
    \addplot[solid,mark=asterisk,mark options={solid},color=blue] {x^2};
    \addplot[solid,mark=asterisk,mark options={solid},color=red] {x^3};  
    \addplot[only marks,mark=star,mark size=2pt,color=black] coordinates{(0,0)};
    \coordinate (spypoint) at (axis cs:0,0); 
    \coordinate (spyviewer) at (axis cs:0.5,-90); 
\end{axis}  
    \spy[width=6cm,height=1cm] on (spypoint) in node [fill=white] at (spyviewer); 

\end{tikzpicture}  

\begin{tikzpicture}
%[spy using outlines={rectangle, magnification=3,connect spies}] 

\begin{axis}[grid=major,no markers,domain=-5:5,enlargelimits=false] 
    \addplot[solid,mark=asterisk,mark options={solid},color=blue] {x^2};
    \addplot[solid,mark=asterisk,mark options={solid},color=red] {x^3};  
    \addplot[only marks,mark=star,mark size=2pt,color=black] coordinates{(0,0)};
    %\coordinate (spypoint) at (axis cs:0,0); 
    %\coordinate (spyviewer) at (axis cs:0.5,-90); 
\end{axis}  
    %\spy[width=6cm,height=1cm] on (spypoint) in node [fill=white] at (spyviewer); 

\end{tikzpicture}  
\end{document}

I'm not allowed to upload an image here since I'm new, but the red and blue graphs disappear with the spy glass, where the black dot remains. The areas of the spy glass are correct, but also the black dot doesn't appear in the zoom area, it's completely empty. When not using spy, the graphs appear perfectly fine...

share|improve this question
    
Here, with TeXLive 2012, your code is ok. And with TeXLive 2009, all is ok except the black mark that does not appear in the graph or in the zooming area (pgfplots is too old). –  Paul Gaborit Jul 11 '12 at 13:10
    
Ok, thanks for the info PolGab, I'll try it on a different machine perhaps that will work. I'll keep you posted! –  Blaatschaap Jul 11 '12 at 15:23
1  
I get the same result as PolGab with texlive 2010. Can you elaborate on your build path? I think pgfplots may interact weirdly with some of the possibilities. (The version I have has an explicit warning about dvipdfm in the source, for example.) I'm building successfully with latexmk -pdf FWIW. –  kgr Jul 11 '12 at 15:54

1 Answer 1

up vote 5 down vote accepted

Ok, that was enough info to sort of track down what is going on. There was a bug in the spy library that caused it to fail with dvips or xelatex. This was reported and apparently fixed here, but I don't think there's actually been a release of pgf/tikz since then, at least not one that is showing up on sourceforge, so updating the tex installation wouldn't help.

You could try subbing in the newest version of this library to your pgf installation (source code here). However I tried doing this and it didn't quite work, though it behaved differently than the buggy behavior (which, incidentally, I was able to replicate) -- the spy part worked but the plot part didn't. Possibly I was doing something wrong and I didn't try very hard. But probably you would need to install the development version of the whole package to fix this bug in the meantime, rather than just updating this one file. Or give up on .ps as you say :).

share|improve this answer
    
kgr you got me on the right track! I was converting with LaTeX => PS => PDF because of .eps figures. Then also on my other machine it didn't work, same stuff. But with LaTeX => PDF it works fine! I was already busy changing .eps to .tikz so skipping PS is no problem. Thanks! –  Blaatschaap Jul 11 '12 at 18:28
    
PGF 3.0.0 (with the problem fixed) was released on December 20, 2013. –  mvkorpel Jun 4 at 10:10

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.