1

How to move the axes in front of plots? The example below produces plots which are blocking the axes. I want those plots to be behind the axes.

\documentclass{article}
\usepackage{paralist,pst-func, pst-plot, pst-math, pstricks-add,pgfplots}
\usetikzlibrary{patterns,matrix,arrows}
\begin{document}
\begin{tikzpicture}
    \begin{axis}[axis lines=center,clip=false,xmin=-4,xmax=4,ymin=0,ymax=1] 
    \addplot[color=lime,fill=lime, samples=100] {1/sqrt(2)*exp(-(x+1)^2/1)} \closedcycle;
    \addplot[color=cyan!40,fill=cyan!40, samples=100] {1/sqrt(2)*exp(-(x-1)^2/1)} \closedcycle;
    \end{axis}
\end{tikzpicture}
\end{document}
  • Add axis on top to the axis options. – Torbjørn T. Dec 29 '17 at 17:14
1

Use axis on top

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\usetikzlibrary{patterns,matrix,arrows}
\begin{document}
\begin{tikzpicture}
    \begin{axis}[axis lines=center,clip=false,xmin=-4,xmax=4,ymin=0,ymax=1,axis on top]
    \addplot[color=lime,fill=lime, samples=100] {1/sqrt(2)*exp(-(x+1)^2/1)} \closedcycle;
    \addplot[color=cyan!40,fill=cyan!40, samples=100] {1/sqrt(2)*exp(-(x-1)^2/1)} \closedcycle;
    \end{axis}
\end{tikzpicture}
\end{document}

enter image description here

  • Impossible to be a more natural solution. Nice! – Sigur Dec 29 '17 at 17:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.