How to convert this Mathematica code to pgfplot?

I have a Mathematica code which I would like to convert into pgfplot only to obtain the contours so that I can use the 'TikZ' version with other drawings made using TikZ. I actually am not familiar with multivariate plotting that much in PGFPLOTS. The code is:

mycolor[z_] := RGBColor[1, 1 - z, 1 - z];
w0 = 0.1;
w[z_] := w0*Sqrt[1 + (z/0.25)^2];
i[r_, z_] := Sqrt[Exp[-(2*r^2)/(w[z]^2)]];
ContourPlot[i[r, z], {z, -1, 0}, {r, -1, 1}, PlotRange -> All,
PlotPoints -> 50, PlotTheme -> "Scientific",
ColorFunction -> mycolor, ColorFunctionScaling -> False,
Frame -> None, Contours -> 6]


The output is:

UPDATE 1

I almost got what I wanted, but for some reasons those black lines don't appear.

\documentclass[border=3mm]{standalone}

\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
view={0}{90},
colormap={custom}{color(0)=(white) color(1)=(red)},
domain=-1:0,
y domain=-1:1,
axis line style={draw=none},
ticks=none
]
contour filled={labels=false,number=6,draw color=black},samples=50
] {sqrt(exp((-2*y^2)/(0.1*sqrt(1 + (x/0.25)^2))^2))};
\end{axis}
\end{tikzpicture}
\end{document}


Output:

UPDATE 2

If I use the feature of draw color of contour lua, I do get the lines I want, but they don't fit with the edges of contour filled one.

\documentclass[border=3mm]{standalone}

\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
view={0}{90},
colormap={custom}{color(0)=(white) color(1)=(red)},
domain=-1:0,
y domain=-1:1,
axis line style={draw=none},
ticks=none,
]
contour filled={labels=false,number=6},samples=50
] {sqrt(exp((-2*y^2)/(0.1*sqrt(1 + (x/0.25)^2))^2))};
contour lua={labels=false,number=6,draw color=black},samples=50
] {sqrt(exp((-2*y^2)/(0.1*sqrt(1 + (x/0.25)^2))^2))};
\end{axis}
\end{tikzpicture}
\end{document}


• Unrelated: When using PGFPlots, you should always set the compat level - see my answer. Commented Mar 29, 2022 at 17:28

I do not know what is going on with the different levels, but this looks like what you want:

\RequirePackage{luatex85}
\documentclass[border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
view={0}{90},
colormap={custom}{color(0)=(white) color(1)=(red)},
domain=-1:0, y domain=-1:1,
axis x line=none, axis y line=none,
]
contour filled={number=7},
samples=50,
] {sqrt(exp((-2*y^2)/(0.1*sqrt(1 + (x/0.25)^2))^2))};
contour lua={labels=false, levels={1/7,2/7,3/7,4/7,5/7,6/7}, draw color=black},
samples=100,
] {sqrt(exp((-2*y^2)/(0.1*sqrt(1 + (x/0.25)^2))^2))};
\end{axis}
\end{tikzpicture}
\end{document}


Edit: From the manual:

/pgfplots/contour/number={⟨integer⟩} (initially 5) Configures the number of contour lines which should be produced by any contouring algorithm. The value is applied to both contour lua and contour filled.

It is apparently not treated in the same way for contour lua and contour filled. For contour filled, the domain is split evenly and for contour lua, the contours are placed, so that they are somehow evenly spaced. -hence the need to give the levels explicitly to match contour filled.

• What is the purpose of levels here? Commented Mar 29, 2022 at 18:01
• number gives the number of contours evenly split. levels explicitly sets the level at which you want the contours. You can experiment with showing the labels to see at what level the contour is at. It should be possible to match the two without setting the levels explicitly by considering the domain and at what level the filling is at. Commented Mar 29, 2022 at 18:10