9

When I use the tikz.spy library in order to magnify a part of my pgfplots plot with the use of grids, there are both the original grid and the magnified grid in the magnified area. screenshot: http://files.droplr.com/files/55004911/YHwt.Plots-Spy-Grid.png.

a part of the code looks like this:

\begin{tikzpicture} [spy using outlines={circle, magnification=3, size=2cm, connect spies}]

\begin{axis}[grid=major,axis on top, ... ]

\addplot ...

\begin{scope}[fill=white]
    \spy[green!70!black,size=5cm] on (10.9,9.1) in node [right] at (3,6);
\end{scope}

\end{axis}
\end{tikzpicture}

Is it possible to have only the magnified grid in the magnified area (e.g. to set the opacity of magnified area? The fill=white command seems to has no effect. I tried the same with the opacity property. spy using overlay doesn't help neither. Another way would be to have the grid only in the magnified area, but I have no idea how to do.

Does anyone has a solution?

Matthew Leingang
  • 44,937
  • 14
  • 131
  • 195
kromuchi
  • 2,187
  • Really nice graph, by the way. Would you mind sharing how you filled the area between the curves? – Jake Mar 28 '11 at 17:07
  • look here: http://goo.gl/EYf90 -- i export the data (tables) for each line with matlab (fprintf) – kromuchi Mar 28 '11 at 17:27

1 Answers1

15

You have to supply the fill=white option to the "in-node":

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

\begin{document}
\begin{tikzpicture} [spy using outlines={circle, magnification=3, size=2cm, connect spies}]
\begin{axis}[grid=major,axis on top,width=14cm]
\addplot +[mark=none] {0.1*x^2};

\begin{scope}
    \spy[green!70!black,size=5cm] on (10.9,8) in node [fill=white] at (6,7);
\end{scope}

\end{axis}
\end{tikzpicture}
\end{document}

spy node with filled background

Jake
  • 232,450