addplot3 上不尊重顶部的轴

addplot3 上不尊重顶部的轴

尽管使用axis on top=false网格覆盖在图表上addplot3。我在使用更简单的图表上应用了相同的方法addplot,并且得到了图表后面网格的预期行为。知道我做错了什么吗?

在此处输入图片描述

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}

\usetikzlibrary{pgfplots.colormaps}

\begin{document}
\begin{tikzpicture}


  \begin{axis}[
      domain=-1:1,
      xmin=-1.2, xmax=1.2,
      colormap/copper,
      grid=major,
      axis on top=false,
      ymin=-1.2, ymax=1.2, zmin=0,
      view={0}{90},
      colorbar horizontal,
      colorbar style={point meta min=0,point meta max=0.7},
      colorbar/width=2.5mm,
      grid=major,
    ]

    \addplot3[
      samples=50,
      contour gnuplot={
        output point meta=rawz,
        levels={0.2,0.4,0.6},
        labels=true,
        handler/.style=smooth,
      },
      z filter/.code=\def\pgfmathresult{0},
    ] gnuplot {
      min(a,b) = (a < b) ? a : b
      r2(x,y) = min(1,(x^2+y^2))
      (x,y,6*(1-r2(x,y))*(27-8*r2(x,y)) / (73 * pi) )
    };
  \end{axis}

\end{tikzpicture}

\end{document}

答案1

欢迎使用 TeX.SE!我猜你需要将样本设置为,然后可以通过使用并在图层上绘制轮廓25来解决你的问题。set layersaxis foreground

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}

\usetikzlibrary{pgfplots.colormaps}

\begin{document}
\begin{tikzpicture}


  \begin{axis}[set layers,
      domain=-1:1,
      xmin=-1.2, xmax=1.2,
      colormap/copper,
      grid=major,
      axis on top=false,
      ymin=-1.2, ymax=1.2, zmin=0,
      view={0}{90},
      colorbar horizontal,
      colorbar style={point meta min=0,point meta max=0.7},
      colorbar/width=2.5mm,
      grid=major,
    ]

    \addplot3[on layer=axis foreground,
      samples=25,
      contour gnuplot={
        output point meta=rawz,
        levels={0.2,0.4,0.6},
        labels=true,
        handler/.style=smooth,
      },
      z filter/.code=\def\pgfmathresult{0},
    ] gnuplot {
      min(a,b) = (a < b) ? a : b
      r2(x,y) = min(1,(x^2+y^2))
      (x,y,6*(1-r2(x,y))*(27-8*r2(x,y)) / (73 * pi) )
    };
  \end{axis}

\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容