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.

My problem is the following. I would like to draw the (magnified) axes on the magnified area of spy. For instance, take the following example (from pgfplots.pdf, p.121):

% Preamble: \pgfplotsset{width=7cm,compat=1.5.1}
% requires \usetikzlibrary{spy} 
\begin{tikzpicture}[spy using outlines=
{circle, magnification=6, connect spies}]
\begin{axis}[no markers,grid=major,
every axis plot post/.append style={thick}]
\addplot  coordinates
{(0, 0.0) (0, 0.9) (1, 0.9) (2, 1) (3, 0.9) (80, 0)};
\addplot +[line join=round] coordinates
{(0, 0.0) (0, 0.9) (2, 0.9) (3, 1) (4, 0.9) (80, 0)};
\addplot +[line join=bevel] coordinates
{(0, 0.0) (0, 0.9) (3, 0.9) (4, 1) (5, 0.9) (80, 0)};
\addplot +[miter limit=5] coordinates
{(0, 0.0) (0, 0.9) (4, 0.9) (5, 1) (6, 0.9) (80, 0)};
\coordinate (spypoint) at (axis cs:3,1);
\coordinate (magnifyglass) at (axis cs:60,0.7);
\end{axis}
\spy [blue, size=2.5cm] on (spypoint)
in node[fill=white] at (magnifyglass);
\end{tikzpicture}

I would like to draw axes (with a new grid) in the magnifyglass to see (approximately) the peak values in (x,y). Kind of like the "Loupe" tool in the DataGraph software. Is this possible?

share|improve this question
    
Welcome at Tex.se! There are a couple of related questions - you may want to search for [pgfplots] spy in the tex.se search bar. The results seem to be highly relevant to your request. See tex.stackexchange.com/questions/42585/… if you want a new, separate axis (maybe with a new grid) –  Christian Feuersänger Jun 28 '12 at 17:51
    
Yes, I saw that question before posting but I really like the spy using outlines={circle, magnification=6, connect spies}, with the circles. I think I have figured a way to achieve this effect. How do I post my code in the replies? –  user12876 Jun 28 '12 at 19:17
2  
You can post an answer to your own question. There, you can highlight it by marking it and pressing CTRL-K. –  Christian Feuersänger Jun 29 '12 at 15:03

1 Answer 1

Remarks

Using the question linked by Christian Feuersänger, I was able to produces an example.

Code

\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.5.1}
\usetikzlibrary{spy}
\begin{document}
\begin{tikzpicture}[every pin/.style={fill=white}]
    \begin{axis}[
            no markers,
            grid=major,
            every axis plot post/.append style={thick}
        ]
        \addplot  coordinates {(0, 0.0) (0, 0.9) (1, 0.9) (2, 1) (3, 0.9) (80, 0)};
        \addplot +[line join=round] coordinates {(0, 0.0) (0, 0.9) (2, 0.9) (3, 1) (4, 0.9) (80, 0)};
        \addplot +[line join=bevel] coordinates {(0, 0.0) (0, 0.9) (3, 0.9) (4, 1) (5, 0.9) (80, 0)};
        \addplot +[miter limit=5] coordinates {(0, 0.0) (0, 0.9) (4, 0.9) (5, 1) (6, 0.9) (80, 0)};
        \coordinate (spypoint) at (axis cs:3,1);
    \end{axis}
    \node[pin={[pin distance=1.5cm]357:{%
        \begin{tikzpicture}[baseline,trim axis left,trim axis right]
            \begin{axis}[
                    no markers,
                    grid=major,
                    every axis plot post/.append style={thick},
                    tiny,
                    xmin=1,xmax=6,
                    ymin=0.95,ymax=1.02,
                ]
                \addplot  coordinates {(0, 0.0) (0, 0.9) (1, 0.9) (2, 1) (3, 0.9) (80, 0)};
                \addplot +[line join=round] coordinates {(0, 0.0) (0, 0.9) (2, 0.9) (3, 1) (4, 0.9) (80, 0)};
                \addplot +[line join=bevel] coordinates {(0, 0.0) (0, 0.9) (3, 0.9) (4, 1) (5, 0.9) (80, 0)};
                \addplot +[miter limit=5] coordinates {(0, 0.0) (0, 0.9) (4, 0.9) (5, 1) (6, 0.9) (80, 0)};
            \end{axis}
        \end{tikzpicture}%
    }},draw,circle,minimum size=0.5cm] at (spypoint) {};
\end{tikzpicture}
\end{document}

Output

enter image description here

share|improve this answer

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.