I would like to plot the following functions with pgfplots
:
I know how they are defined:
\sqrt{r}\sin\frac{\theta}{2}, \sqrt{r}\sin\frac{\theta}{2}\sin\theta,
\sqrt{r}\cos\frac{\theta}{2}, \sqrt{r}\cos\frac{\theta}{2}\sin\theta
but nothing else (for example the domain).
I'll post soon my solution (which is far from what I'm looking for), but I would like to now your opinion from now.
EDIT: here is my attempt to reproduce the first function:
\documentclass{scrbook}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.5.1}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xtick=\empty,
ytick=\empty,
ztick=\empty,
unbounded coords=jump,
]
\addplot3[
surf,
faceted color=blue,
samples=20,
domain=-1:1, y domain=-5:0]
{sqrt(x^2+y^2)*sin(0.5*atan(y/x))};
\end{axis}
\end{tikzpicture}
and here is the result:
I know, it's very different from how it should be, but I don't know how to improve it.
Best Answer
You can plot polar functions by setting
domain=<your theta domain>, y domain=<your r domain>, data cs=polar
. Using this approach, the jumps in your functions will be plotted correctly.In this example, I've used the same color range for all four plots (by setting
point meta min
andpoint meta max
explicitly). That way, you can immediately see that the functions span different z-ranges. If you don't want that, just delete thepoint meta min/max
keys.If you want the plots to fill out the whole x/y plane, you'll need to stretch
r
accordingly. I've defined two functions here,stretch
that does just that. It needs to be applied to bothy coord trafo
and to the function to be plotted. In conjunction withshader=interp
, we're getting pretty close to the original plots:Code for circular polar plots
Code for square polar plots