I am trying to learn how to use pgfplots
by plotting simple things, like a two-dimensional sphere. However, I find it quite surprising that depending on the view angle, the result sometimes does not look like a sphere at all. Unless I am missing something, a sphere should like the same no matter which direction we are looking from.
Here is my example code:
\documentclass[a4paper,landscape]{article}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{width=6cm}
\newcommand{\degree}{\ensuremath{^\circ}}
\newcommand{\plotsphere}[2]{
\begin{axis}[view={#2}{#1},axis equal,title={$\theta=#1\degree,\quad \phi=#2\degree$}]
\addplot3[surf,shader=flat,z buffer=sort,
samples=20,domain=-1:1,y domain=0:2*pi]
({sqrt(1-x^2) * cos(deg(y))},
{sqrt( 1-x^2 ) * sin(deg(y))},
x);
\end{axis}
}
\begin{document}
\pagestyle{empty}
\begin{figure}
\begin{tikzpicture}[scale = 0.75]
\foreach \x/\polangle in {-8/20,0/45,8/70}
\foreach \y / \azangle in {-8/20,0/45,8/70}
\node at (\x,\y) {\plotsphere{\polangle}{\azangle}};
\end{tikzpicture}
\end{figure}
\end{document}
and the result:
The only version I am satisfied with is view={45}{45}
. All the other ones appear distorted. It seems that this distortion does not come from different length units on the axis because I am using the axis equal
option. Am I forgetting some important parameter?
axis equal image
.pgfplots
(1.5.1) I had, usingaxis equal image
didn't solve the problem, but upgrading to (1.6) as @Luigi suggested solves the problem, thank you very much (then I can use any axis scaling as illustrated in your answer).