I'm trying to plot the ramification/Riemann surface of the square root in the complex plane (e.g. Wikipedia).
To encode the imaginary part of the square root, I try to provide specific values for the color using wave format for color input.
I use polar coordinates (x cos(y), x sin(y)) and the real part of the square root should be sqrt(x) cos(y/2), while the imaginary part for the color is sqrt(x) sin(y/2).
Consider the following code:
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot3 [
surf,
domain=0:4,
domain y=-pi:3pi,
mesh/color input=explicit mathparse,
point meta={symbolic={wave=363+(2+sqrt(x)sin(deg(y/2)))/4*(814-363)}}
]
(x,y,0); % This works just fine
% ({xcos(deg(y))}, {xsin(deg(y))}, {sqrt(x)*cos(deg(y/2))}); % This breaks!
\end{axis}
\end{tikzpicture}
\end{document}
Plotting a horizontal plane yields no problems. But using the actual plot, I obtain the following error message:
Package pgfplots Error: Sorry, the color component value nan (no. 0) is out of range. The allowed range is 0 <= value <= 1. The error occured near `point meta 'wave=363+(2+sqrt(x)*sin(deg(y/2)))/4*(814-363)' of coord no 6 (2Y9.99975739e-1],2Y3.141592654e0],0Y0.0e0])'.
This also happens at other coordinates.
Edit: I boiled it down to the first argument, the cos(deg(y)) seems to be the problem.
Edit: How it should look like:
This image is taken from Wikipedia. Note the color distribution. For example, yellow, green and cyan appear two times, but blue and red only once. More precisely, the two yellow parts are not precisely on top of another, but reflected along the real line.
Edit: Just writing what I wrote as a comment: Let alone this code, which is very similar to the example in the official documentation, p. 151, fails with some modifications.
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot3 [
surf,
domain=0:1,
domain y=0:1,
mesh/color input=explicit mathparse,
point meta={symbolic={wave=363+x*(814-363)}}
]
(x,y,0); % This works just fine
% (y,x,0); % This breaks!
\end{axis}
\end{tikzpicture}
\end{document}






deg(y)since TikZ/the PGF engine expects degrees, not radians. Converting everything to degrees (i.e.domain y=-180:3*180) yields the same problem. – Gargantuar Jul 13 '23 at 08:39wave=thing is not working here, trypoint meta={symbolic={wave=363+x/4*(814-363)}}– Rmano Jul 13 '23 at 09:34xthere is what we expect it to be; I had errors with a negative value (try it!) – Rmano Jul 13 '23 at 10:09