# Random closed line on a 3d sphere

I want to draw a random closed line (like a bit deformed circle) on the surface of 3d sphere. It should look like one has cut a small part from the sphere. It should be located on the northern hemisphere. Once the sphere should be highlighted by a shade of lines except that "circle", and once inverted.

Until now I managed to draw a sphere:

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[thick,->] (0,0,0) -- (3,0,0) node[anchor=north east]{$x$};
\draw[thick,->] (0,0,0) -- (0,3,0) node[anchor=north west]{$z$};
\draw[thick,->] (0,0,0) -- (0,0,3) node[anchor=south]{$y$};

\draw (0,0) circle (2cm);
\draw (-2,0) arc (180:360:2 and 0.6);
\draw[dashed] (2,0) arc (0:180:2 and 0.6);
\fill[fill=black] (0,0) circle (1pt);

\end{tikzpicture}
\end{document}


• Welcome to TeX.SE! I'm afraid the code you posted doesn't compile. You should probably remove the $$ and $$ (please test your code and edit your post). Also, what you want to obtain is hard to guess; most probably, a hand-drawing would help clarify your wishes. – frougon Jun 20 '19 at 12:16

Here is a manual yet simple solution that does not require too much code.

• The hobby library provides solutions to create closed blobby shapes.
• The patterns library is used to fill shapes with patterns.
• The even odd rule can be used to fill the circle but not the blob within.
\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{patterns,hobby}
\begin{document}
\begin{tikzpicture}

\draw  (0,0) circle (2cm);
\draw[use Hobby shortcut,closed=true,pattern=north east lines]
(-0.2,0.3) .. (0.2,0.2) .. (1.1,0.6) .. (1.1,1) .. (0.3,1.4) .. (-0.4,1.2) .. (-0.3,0.8);
\draw (-2,0) arc (180:360:2 and 0.6);
\draw[dashed] (2,0) arc (0:180:2 and 0.6);
\fill[fill=black] (0,0) circle (1pt);

\begin{scope}[xshift=5cm]
\draw[use Hobby shortcut,closed=true,pattern=north east lines,even odd rule]  (0,0) circle (2cm)
(-0.2,0.3) .. (0.2,0.2) .. (1.1,0.6) .. (1.1,1) .. (0.3,1.4) .. (-0.4,1.2) .. (-0.3,0.8);
\draw (-2,0) arc (180:360:2 and 0.6);
\draw[dashed] (2,0) arc (0:180:2 and 0.6);
\fill[fill=black] (0,0) circle (1pt);
\end{scope}

\end{tikzpicture}
\end{document}


• Thank you very much! This is what I looked for! Besides, it is a very good explanation that helps me for further purposes! – mscm Jun 20 '19 at 13:29