# How can I draw shells with TikZ? [duplicate]

This question already has an answer here:

At first, I try to draw a cylinder which is much different from what I want....

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.4}
\usepackage{tikz-3dplot}
\tdplotsetmaincoords{60}{-30}
\tdplotsetrotatedcoords{0}{90}{90}%
\begin{document}
\begin{tikzpicture}
[tdplot_rotated_coords,
scale=3,
mdc/.style={fill=blue, color=blue,draw=none, opacity=.4,line join=round},
length/.style={<->,thick,line cap=round}]
\def\d{1}
\def\r{\d*.45}

% Cylinder
\foreach \t in {0,12,...,348}
\draw[mdc] ({cos(\t   )*\r+\d/2},  0, {sin(\t   )*\r+\d/2}) % side vertice of cylinder
-- ({cos(\t+12)*\r+\d/2},  0, {sin(\t+12)*\r+\d/2})
-- ({cos(\t+12)*\r+\d/2}, \d, {sin(\t+12)*\r+\d/2})
-- ({cos(\t   )*\r+\d/2}, \d, {sin(\t   )*\r+\d/2})
-- cycle;
\end{tikzpicture}
\end{document}


I am curious to know that it is possible to draw shell figures with TikZ (like bellow pictures), but the above code and figures below are far different from what I want....

## marked as duplicate by cfr tikz-pgf StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var$hover = $(this).addClass('hover-bound'),$msg = $hover.siblings('.dupe-hammer-message');$hover.hover( function() { $hover.showInfoMessage('', { messageElement:$msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Mar 29 '17 at 0:32

• Yes, it's certainly possible but rather than asking people to do all of the work for you you should show us what you have tried. Posting a minimal working example makes it easier for people to help you, since they have some code to start from, and much more likely that some one will try to help you. – Andrew Oct 27 '16 at 3:44
• OK thank you, I try to draw a cylinder, but there is much different between what I have and what I want. – sayros Oct 27 '16 at 6:52
• Instead ofTikZ you could try with Asymptote – Ignasi Oct 27 '16 at 7:03
• Related tikz example: texample.net/tikz/examples/spherical-polar-pots-with-3dplot – Andrew Oct 27 '16 at 11:34
• TikZ is not a good choice for this as it only draws in 2D. You can fake 3D in simple cases. Also, what do you want? If you don't want either what your code produces or the figures shown at the bottom of your post, how do we know what other non-specified thing you are trying to achieve? – cfr Feb 26 '17 at 23:43

I use the following code, which may not be perfect:

\documentclass{standalone}
\usepackage{tikz}
\tikzset{
pics/.cd,
shell/.style = {
code = {
\path [top color = black!25, bottom color = white]
(0,.05*6/3) ellipse [x radius = 3-.05, y radius = 2-.032];
\path [left color = black!25, right color = black!25, middle color = white]
(-3,0) -- (-3,-2) arc (180:360:3 and 2)
-- (3,0) arc (360:180:3 and 2);
\foreach \r in {225,315}
\foreach \i [evaluate = {\s=30;}] in {0,2,...,30}
\fill [black, fill opacity = 1/50]
(0,0.2) -- (\r+\s-\i:3 and 2) -- ++(0,-2)
arc        (\r+\s-\i:\r-\s+\i:3 and 2) -- ++(0,2) -- cycle;
\foreach \r in {45,135}
\foreach \i [evaluate = {\s=30;}] in {0,2,...,30}
\fill [black, fill opacity = 1/50]
(0,0.2) -- (\r+\s-\i:3 and 2)
arc (\r+\s-\i:\r-\s+\i:3 and 2)  -- cycle;
\path [top color = white, bottom color = white]
(0,.05*6/3) ellipse [x radius = 2-.05, y radius = 4/3-.05*4/3];
}
}
}
\begin{document}
\begin{tikzpicture}
\path (0,0,0) pic {shell} ;
\end{tikzpicture}
\end{document}


• Please post a complete minimal working example (MWE), instead of pieces to put togheter... – CarLaTeX Feb 26 '17 at 8:59
• Isn't this part of Mark's answer to another question? – cfr Feb 26 '17 at 23:47