## LaTeX forum ⇒ Graphics, Figures & Tables ⇒ Shaded ellipsoid with PGFplots

Information and discussion about graphics, figures & tables in LaTeX documents.
Tyrion1989
Posts: 2
Joined: Thu Aug 13, 2015 1:05 pm

Hey, I'm trying to display a shaded 3D ellipsoid with axis labels with PGFplots. So far I achieved this.
\documentclass{standalone}\usepackage{tikz}\usepackage{pgfplots,tikz-3dplot}\begin{document}\begin{tikzpicture}     \begin{axis}[%     	width=0.8\textwidth,         axis equal,         axis lines = center,         y label style={at={(axis cs:0,2,0)},anchor=west},         xlabel = {$\lambda_1,\ \vec{e}_1$},         ylabel = {$\lambda_2,\ \vec{e}_2$},         zlabel = {$\lambda_3,\ \vec{e}_3$},         ticks=none,     ]     \addplot3[%     	shader=interp,         opacity = 0.3,         fill opacity=0.3,         surf,         colormap/blackwhite,         variable = \u,         variable y = \v,         domain = 0:180,         y domain = 0:360,     ]     ({2*cos(u)*sin(v)}, {2*sin(u)*sin(v)}, {0.5*cos(v)});     \end{axis}\end{tikzpicture}\end{document}

The z label is at the right position in my PDF document, I dont't know why it is deplaced here.
This shading does not give a 3D impression, I would like to have somethin like in the attached file. Is it possible to define a new 3d shading in this coordinate system? I could not find such a command in the pgfplot documentation. All predefined shadings are not suitable.
Attachments
FA_tensor.png (52.96 KiB) Viewed 2132 times

Tags:

Stefan Kottwitz
Posts: 8703
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:
Welcome to the forum!

You could use point meta = u. And you could play with the colormap, as I did on the axis.

I added colormap={}{ gray(0cm)=(0.8); gray(1cm)=(0);} and point meta = u to the plot:

ellipsoid.png (20.53 KiB) Viewed 2115 times

edit: above was rendered from PDF to PNG by GIMP, seems to become too dark, here's how my previewer and Overleaf render it:

ellipsoid-lighter.png (28.65 KiB) Viewed 2110 times

Full code:

\documentclass{standalone}\usepackage{tikz}\usepackage{pgfplots,tikz-3dplot}\makeatother\begin{document}\begin{tikzpicture}     \begin{axis}[%         width=0.8\textwidth,         axis equal,         axis lines = center,         y label style={at={(axis cs:0,2,0)},anchor=west},         xlabel = {$\lambda_1,\ \vec{e}_1$},         ylabel = {$\lambda_2,\ \vec{e}_2$},         zlabel = {$\lambda_3,\ \vec{e}_3$},         ticks=none,         colormap={}{ gray(0cm)=(0.8); gray(1cm)=(0);}     ]     \addplot3[%         shader=interp,         opacity = 0.3,         fill opacity=0.3,         surf,         variable = \u,         variable y = \v,         domain = 0:180,         y domain = 0:360,         point meta=u,         samples = 50,     ]     ({2*cos(u)*sin(v)}, {2*sin(u)*sin(v)}, {0.5*cos(v)});     \end{axis}\end{tikzpicture}\end{document}

Stefan

Tyrion1989
Posts: 2
Joined: Thu Aug 13, 2015 1:05 pm
Hi, the problem is that the shading coordinate system is still wrong. I want the shading to look like if a light bulb would shine on the ellipsoid. So the colormap should extend from the top maybe and extend in all direction isotropically. Right now there is this "line" dividing the ellipsoid into two halfs. The grey parts on the left side of the upper half should be right so the shading has to be flipped at the y axis for the upper half.

I will try to seperate the ellipsoid into two plots, just have to change the variable domains.

Thanks!