# Drawing a shaded hemisphere using tikz?

I want to draw a shaded hemisphere using tikz. The final result should look like this (the lower part of the sphere should be removed):

Until now I have this code:

\documentclass{article}

\usepackage{tikz}
\usepackage{tikz-3dplot}

\usepackage[active,tightpage]{preview}  %generates a tightly fitting border around the work
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{2mm}

\begin{document}

\tdplotsetmaincoords{60}{110}

%define polar coordinates for some vector
%TODO: look into using 3d spherical coordinate system
\pgfmathsetmacro{\thetavec}{0}
\pgfmathsetmacro{\phivec}{0}

%start tikz picture, and use the tdplot_main_coords style to implement the display
%coordinate transformation provided by 3dplot
\begin{tikzpicture}[scale=5,tdplot_main_coords]

--

%draw the main coordinate system axes
\draw[thick,->] (0,0,0) -- (-1,0,0) node[anchor=south]{$z$};
\draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$x$};
\draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$y$};

\tdplotsetthetaplanecoords{\phivec}

%draw some dashed arcs, demonstrating direct arc drawing

% (-z x y)
\draw (0, 1, 0) node [circle, fill=blue, inner sep=.02cm] () {};
\draw (0, 0, 1) node [circle, fill=green, inner sep=.02cm] () {};
\draw (-1, 0, 0) node [circle, fill=red, inner sep=.02cm] () {};

\end{tikzpicture}

\end{document}


Is there any possibility to get rid of the lower part of the sphere?

• Something like this? I would have posted an answer already but there is a small imperfection in the lower left side. I'll try to fix it. Jun 17 '15 at 11:32
• @Alenanno yes - looks very good.I hope you can fix the small problem on the lower left side. Jun 17 '15 at 11:51
• See the answer. I realize I have been looking for the harder solution when there was a simpler one in front of me all the time. Jun 17 '15 at 22:11
• You might want to consider Asymptote if you need to add complexity and real 3D (see this post). Jun 17 '15 at 22:17

I was so focused into using intersection segments that I didn't think of a simpler solution. Simply draw the lower arc (middle section) and then the dome and shade the path.

Basically this is what the path looks like:

## Code

\documentclass[margin=10pt]{standalone}
\usepackage{tikz}
\usepackage{tikz-3dplot}

\begin{document}
\tdplotsetmaincoords{60}{110}

%define polar coordinates for some vector
%TODO: look into using 3d spherical coordinate system
\pgfmathsetmacro{\thetavec}{0}
\pgfmathsetmacro{\phivec}{0}

%start tikz picture, and use the tdplot_main_coords style to implement the display
%coordinate transformation provided by 3dplot
\begin{tikzpicture}[scale=5,tdplot_main_coords]
%draw the main coordinate system axes
\draw[thick,->] (0,0,0) -- (-1,0,0) node[anchor=south]{$z$};
\draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$x$};
\draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$y$};

\tdplotsetthetaplanecoords{\phivec}

%draw some dashed arcs, demonstrating direct arc drawing