pgf-tikz / pgfplots

pgfplots - A TeX package to draw normal and/or logarithmic plots directly in TeX in two and three dimensions with a user-friendly interface and pgfplotstable - a TeX package to round and format numerical tables. Examples in manuals and/or on web site.
http://pgfplots.sourceforge.net/
198 stars 34 forks source link

`spy` breaks `grid` and `fill between` #103

Open pgf-tikz-bot opened 8 years ago

pgf-tikz-bot commented 8 years ago

Migrated from SourceForge https://sourceforge.net/p/pgfplots/bugs/103/ Author: mo-gul Timestamp: 2016-02-02 17:03:27.538000

When I add a spy the grid as well as the fill between path get broken and are not drawn any more.

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
    \usetikzlibrary{
        spy,
        pgfplots.fillbetween,
    }
    \pgfplotsset{compat=1.13}
\begin{document}
    \begin{tikzpicture}[
        spy using outlines={
            circle,
            magnification=4,
            size=2cm,
            connect spies,
        },
    ]
        \begin{axis}[
            xmin=0,
            xmax=7,
            ymin=0,
            ymax=30,
            grid=major,
        ]
            \addplot+[name path=A,domain=0:6] {x^2};
            \path[name path=B]
                (\pgfkeysvalueof{/pgfplots/xmin},0) --
                (\pgfkeysvalueof{/pgfplots/xmax},0);
            \addplot[red!10] fill between
                [of=A and B, soft clip={domain=1:5}];

            \coordinate (point to spy) at (1,0);
            \coordinate (show magnification) at (2,20);
        \end{axis}
% uncomment me to show the bug(s)
%        \spy [red] on (point to spy)
%            in node [fill=white] at (show magnification);
    \end{tikzpicture}
\end{document}

This bug can now also be found on TeX.SX:

pgf-tikz-bot commented 7 years ago

Migrated from SourceForge https://sourceforge.net/p/pgfplots/bugs/103/#e459 Author: bz-mof Timestamp: 2017-05-07 15:44:47.318000

I ran into the same problem. And while trying to find a workaround I found out that fillbetween itself isn't the problem. It has something to do with the layer settings. Adding these snippets to any picture using \spy breaks the whole thing like in your example:

/pgfplots/layers/TestLayers/.define layer set={axis background,axis grid,axis ticks,pre main,main,axis lines,axis tick labels,axis descriptions,axis foreground}{/pgfplots/layers/standard},
\begin{axis}[set layers=TestLayers,

As fillbetween uses similar code, this is probably the reason that fillbetween clashes with spy.

Just as a side-note: axis on top works fine.

pgf-tikz-bot commented 5 years ago

Migrated from SourceForge https://sourceforge.net/p/pgfplots/bugs/103/#0b83 Author: mo-gul Timestamp: 2018-12-08 07:10:16.335000

There was added an answer to the question that states that behavior is not a bug in PGFPlots but a core PGF bug.

e-dervieux commented 1 year ago

I just created a ticket in PGF here: https://github.com/pgf-tikz/pgf/issues/1277